This code dont work. The leds turn on and off at the same time. Im new to coding and maybe DELAY is not the right way to go. Would apriciate any pointers ![]()
int Led1Pin = 2; // pin that turns on Led 1
int Led2Pin = 4; // pin that turns on Led 2
int Led1time = 1; // how long Led 1 is on
int Led2time = 5; // how long Led 2 is on
int Led1wait = 5; // how long Led 1 is off before turning on again
int Led2wait = 10; // how long Led 2 is off before turning on again
void setup()
{
pinMode(Led1Pin, OUTPUT); // set 2 to an output so we can use it to turn on the Led 1
pinMode(Led2Pin, OUTPUT); // set 4 to an output so we can use it to turn on the Led 2
}
void loop()
{
digitalWrite(Led1Pin, HIGH); // turn on Led 1
digitalWrite(Led2Pin, HIGH); // turn on Led 2
delay(Led1time1000); // multiply by 1000 to translate seconds to milliseconds
delay(Led2time1000); // multiply by 1000 to translate seconds to milliseconds
digitalWrite(Led1Pin, LOW); // turn off Led 1
digitalWrite(Led2Pin, LOW); // turn off Led 2
delay(Led1wait1000); // multiply by 1000 to translate seconds to milliseconds
delay(Led2wait1000); // multiply by 1000 to translate seconds to milliseconds
}