If you’re just starting with Arduino, one of the simplest but most fun projects is controlling multiple LEDs. In this guide, we’ll show you how to toggle two LEDs — a red one on pin 13 and a blue one on pin 12 — using Arduino.
Materials Needed
-
Arduino Uno (or any Arduino board)
-
Red LED
-
Blue LED
-
100Ω Resistors
-
Jumper wires
Circuit Diagram
Tip: Always connect the short leg (cathode) of the LED to GND, and the long leg (anode) to the resistor and Arduino pin.
Connection Diagram
-
Arduino Uno
-
Two LEDs
-
Resistor
Then connect Pin 13 → Red LED, Pin 12 → Blue LED, and both cathodes to GND using jumper wires.
Arduino Code
Here’s the full code to toggle the LEDs:
How It Works
-
Setup:
-
pinMode()sets pin 13 and pin 12 as outputs.
-
-
Loop:
-
The red LED turns on while the blue LED turns off for 1 second.
-
Then the blue LED turns on while the red LED turns off for 1 second.
-
This creates a toggling effect between the two LEDs.
-
-
Delay:
-
delay(1000)controls the speed of toggling. -
You can change
1000to500for faster blinking or2000for slower.
-
Tips for Beginners
-
Always use a resistor in series with LEDs to prevent burning them out.
-
If LEDs don’t light, check connections: anode (+) goes to pin/resistor, cathode (-) goes to GND.
-
You can extend this project by adding more LEDs or using buttons to toggle manually.