
Video
Circuit Diagram

Source Code
1void setup() {
2 pinMode(8,OUTPUT);
3 pinMode(9,OUTPUT);
4}
5void loop() {
6 digitalWrite(8,HIGH);
7 digitalWrite(9,LOW);
8 delay(200);
9 digitalWrite(8,LOW);
10 digitalWrite(9,HIGH);
11 delay(200);
12}FAQ
Can two LEDs be connected to the same resistor?▾
No, each LED must have its own resistor. If a single resistor is shared among them, the LEDs will not share the current equally; one will glow brighter or won’t light up at all. In this project, there is a separate 220 Ω resistor for each LED.
How does the flip-flop effect work?▾
When one LED is set to HIGH, the other is set to LOW; after a brief pause, their states switch. This causes the two LEDs to light up alternately. Writing opposite values to the two pins at the same time is the basis of this effect.
Which pins can I use?▾
On the Uno, all digital pins from 2 to 13 can be used to drive LEDs. Since pins 0 and 1 are used for USB serial communication, it is recommended that you leave them unused. If you change the pin, be sure to update the pin number in the code as well.
The LEDs are very dim. Why is that?▾
The `pinMode(pin, OUTPUT)` line is often omitted; a pin that isn't set to output will cause the LED to glow dimly. Also, if the resistance value is too high (e.g., 10 kΩ), the LED will glow dimly; use 220–330 Ω.
