Blink an LED with Arduino Uno
The classic first Arduino project: make an LED turn on and off once per second. Learn digital output, pinMode, and the loop.
Beginner10 min
What you need
Wiring
Hover a pin or a wire to trace the connection.
Code
blink.ino
// Blink an LED on pin 13 once per second.
// Pin 13 (LED_BUILTIN) also drives the Uno's onboard LED.
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // set pin 13 as an output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // LED on
delay(1000); // wait 1 second
digitalWrite(LED_BUILTIN, LOW); // LED off
delay(1000); // wait 1 second
}
Steps
- Push the LED into the breadboard. The long leg is the anode (+).
- Connect Arduino D13 to the LED's anode through the 220Ω resistor.
- Connect the LED's short leg (cathode) to an Arduino GND pin.
- Upload the sketch. The LED blinks once per second.