I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital.
Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.
How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.
int ledPin1= 2;
int ledPin2 = 4;
int ledPin3 = 7;
void setup(){
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop(){
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
delay(500);
digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin2, LOW);
delay(1000);
digitalWrite(ledPin3, HIGH);
delay(1500);
digitalWrite(ledPin3, LOW);
delay(1500);
}
So far this is the code. But it delays the whole program. Need leds on at given times.