Light Your First LED
Wire up your first circuit and write the code that makes a light blink — the “hello world” of electronics.
What you'll learn
- How to build a simple circuit on a breadboard and connect it to the Arduino
- What a digital output is, and how the Arduino turns a pin on (HIGH) and off (LOW)
- Why an LED needs a resistor, and which way it has to face
What you'll build: a single LED on a breadboard that blinks on and off, controlled by code you upload to the Arduino.
Components Needed
- 1× Arduino Uno
- 1× USB programming cable
- 1× Breadboard
- 1× LED (any colour)
- 1× 220Ω resistor colour bands: red–red–brown
- 2× Male-to-male jumper wires
Connections
Build this circuit. Take your time — getting the LED facing the right way is the whole game.
| From | To |
|---|---|
| Arduino pin 12 | one end of the 220Ω resistor |
| other end of the 220Ω resistor | the LED's long leg (the + side, the anode) |
| the LED's short leg (the − side, the cathode) | the breadboard − (GND) rail |
| Arduino GND pin | the breadboard − (GND) rail |
Tutorial
Wire the circuit exactly as the table above. Nothing is powered yet — plug the USB cable into the Arduino only after you've checked the LED's long leg goes to the resistor side.
Open the Arduino IDE, type in this code, and upload it to your board:
// Define which pin the LED is connected to #define LED_PIN 12 // setup() runs once when the board powers on void setup() { pinMode(LED_PIN, OUTPUT); // tell pin 12 it's an OUTPUT (it sends power out) } // loop() runs over and over, forever void loop() { digitalWrite(LED_PIN, HIGH); // turn the LED ON (HIGH = 5 volts out) delay(500); // wait 500 ms (half a second) digitalWrite(LED_PIN, LOW); // turn the LED OFF (LOW = 0 volts) delay(500); // wait another half a second }
Once it uploads, your LED should blink on for half a second, off for half a second, forever. That's it — you just controlled the physical world with code.
Try for Yourself
Now make it yours. Try these before peeking at the answers:
- Change the blink speed. Make it blink faster, then slower.
- Move the LED to a different pin (like pin 2, 3, or 11) — and update the code to match.
- Add a pattern. Make the LED blink three times quickly, then pause for a full second, then repeat.
💡 Answers ›
1. Change both delay(500) numbers. delay(100) = fast strobe; delay(1000) = slow, calm blink. Smaller number = faster.
2. Rewire the LED to the new pin, then change one line: #define LED_PIN 2 (or whichever pin you used).
3. Replace loop() with a short for loop that blinks 3× fast, then a delay(1000) before it repeats.
What Actually Just Happened?
The Arduino has a row of digital pins — little switches it can flip with code. When you wrote digitalWrite(LED_PIN, HIGH), you told pin 12 to push out 5 volts. That voltage pushes a tiny current through the resistor, through the LED, and out to GND — and a glowing LED is just what an LED does when current flows through it the right way. LOW sets the pin back to 0 volts, so no current flows and the light goes out. delay() simply makes the Arduino wait, so instead of switching millions of times a second (too fast to see), you get a visible blink.
Troubleshooting
Nine times out of ten it's backwards. Check the LED's long leg — it should be on the resistor side (the + side). If the legs are swapped, current can't flow. Pull the LED out, flip it around, and try again.
The code probably didn't upload. In the Arduino IDE, check Tools → Board is set to Arduino Uno, and Tools → Port is the port that appears when you plug the board in.
Always on? You may have wired the LED straight to 5V instead of pin 12. Very dim? Double-check you used the 220Ω resistor (red–red–brown), not a much larger one.
