LED Blinker
Classic Arduino blink: LED on pin 13 with resistor to GND.
- Beginner
- LED & Lighting
- 4 parts
Opens in your browser with the parts, wiring and code already in place. Press Run to watch it work, then change anything you like.
How it works
The Arduino’s pin 13 is wired through a resistor to the LED’s anode, and the LED’s cathode goes to ground. When the sketch sets pin 13 high it puts 5 volts across that path and current flows, lighting the LED; when it sets the pin low, the current stops. The resistor limits the current so the LED is not damaged. On its own an LED would draw far more than it can take.
setup() makes pin 13 an output and starts the serial connection. loop() then repeats forever: switch the pin on, print “LED ON”, wait 1000 milliseconds (one second), switch it off, print “LED OFF”, wait another second. Open the Serial tab while it runs to watch the messages arrive in step with the light.
Parts
- Arduino Uno
- Resistor
- LED
- GND
Wiring
- Arduino Uno D13 → Resistor A
- Resistor B → LED Anode (+)
- LED Cathode (-) → GND
Arduino code
// LED Blinker
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(13, HIGH);
Serial.println("LED ON");
delay(1000);
digitalWrite(13, LOW);
Serial.println("LED OFF");
delay(1000);
}
Try changing it
- Change both delay(1000) lines to delay(250) and the LED blinks four times as fast.
- Use a different pin: change 13 to 8 in the code, and move the wire in the editor from pin D13 to D8.
- Make a quick flash with a long rest: change the first delay(1000) to delay(100).