beginner 15 minLEDBasics
Blink an LED
The hello-world of electronics: make an LED flash once a second and learn how a digital pin works.
Blinking an LED teaches the three ideas behind every Arduino project: a pin can be an output, HIGH means 5 volts, and delay() pauses the program. Once this works, every other project is a variation of it.
Build it
- 1
Place the LED
Push the LED into the breadboard. The longer leg is positive (anode).
- 2
Add the resistor
Connect a 220 ohm resistor from the LED's short leg to the ground rail. The resistor limits the current so the LED does not burn out.
- 3
Wire it to the board
Run a jumper from pin 13 to the LED's long leg, and another from GND on the board to the ground rail.
- 4
Upload the code
Open the Arduino IDE, paste the sketch below, choose your board and port, and press Upload. The LED blinks once a second.
The code
blink-an-led.ino
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}