Controlling LEDs on and off time with serial monitor

Hi all,

I was just needing some help with controlling several LEDs on and off times through serial monitor. I will provide the code I am currently using just to turn them on and off through the monitor. Any help would be appreciated and it should be a pretty quick solution.

void setup()

{

pinMode(13, OUTPUT);

Serial.begin(9600);

while (!Serial);

Serial.println("Input 1 to Turn LED on and 2 to off");

}

void loop() {

if (Serial.available())

{

int state = Serial.parseInt();

if (state == 1)

{

digitalWrite(13, HIGH);

Serial.println("Command completed LED turned ON");

}

if (state == 2)

{

digitalWrite(13, LOW);

Serial.println("Command completed LED turned OFF");

}

}

}

Here are three tutorials you can follow to reach your goal.

1). Learn about "Blink without Delay"

  1. Learn about "Blink without Delay" with different on and off times
    Arduino: Independent On-Off Times with Millis() - Bald Engineer

  2. Learn the best ways to enter data from the Serial Monitor.
    Serial Input Basics

If you can not put what you learn into something that meets your needs, please come back with your best effort and with any further questions you have.