Learning Goals 5 min
By the end of this lesson you will be able to:
- Wire an external LED to digital pin
13on the Arduino through a 220 Ω current-limiting resistor, with the LED in the correct polarity. - Tell the anode (long leg) from the cathode (short leg) of any LED by sight, and explain why the resistor must always be in series — never in parallel — with the LED.
- Re-upload the Blink sketch from L01-02 and watch your external LED blink in step with the onboard
LLED on pin 13.
Warm-Up 10 min
Last lesson we decoded resistor colour bands. Today we put that 220 Ω red-red-brown-gold resistor to work alongside an LED — the most-used pair of parts in all of electronics.
Quick-fire puzzle
Aisyah holds up a brand-new red LED and a 9 V battery. She is about to clip the LED's two legs straight onto the battery terminals — no resistor, no Arduino — just LED + battery.
- What do you predict will happen in the first 1–2 seconds?
- Using Ohm's Law and assuming the LED itself has almost no resistance, roughly how much current would try to flow?
- What single component, costing about RM 0.20, would have saved the LED?
Reveal the answer
- The LED will flash brightly for a fraction of a second, then burn out. You may see a tiny puff of smoke.
I = V ÷ R. With almost no resistance in the path,Ris tiny — soIis huge. Hundreds of milliamps. A red LED is rated for about 20 mA. It cannot survive a flood that large.- A resistor. Putting one in series with the LED limits the current to a safe value. That is the entire job of the 220 Ω resistor in today's circuit.
Every external LED you ever wire — in this course, on a hobby project, inside a real product — sits next to a resistor for this reason.
New Concept 20 min
The big idea — an LED is a one-way valve
An LED is like a tiny water valve that only opens in one direction. When current is pushed in through the long leg (the anode) it flows out the short leg (the cathode) and the bulb glows. Push current the wrong way — in through the short leg — and the valve stays shut. No light.
Anatomy of an LED
| Feature | What it tells you |
|---|---|
| Long leg | This is the anode (+). Current enters here. |
| Short leg | This is the cathode (−). Current leaves here. |
| Flat side on the round body | The flat side is on the cathode. Useful when the legs have been trimmed equal. |
| Inside the bulb | The smaller metal piece is the anode wire; the bigger cup-shaped piece is the cathode. |
Wiring this lesson's circuit
One LED. One resistor. Two jumper wires. The Arduino's pin 13 supplies the signal; the Arduino's GND pin completes the circuit.
| From | To | Notes |
|---|---|---|
Arduino pin D13 | Breadboard A6 | Yellow jumper. This is the signal wire — when pin 13 goes HIGH, it pushes 5 V into the circuit. |
| Resistor leg 1 | Breadboard D6 | Same column as the yellow wire (col 6). The column-tie strip joins them. |
| Resistor leg 2 | Breadboard D11 | The resistor lies flat across row D, bridging col 6 and col 11. |
| LED anode (long leg) | Breadboard B11 | Same column as the resistor's right leg (col 11). Current arrives from the resistor. |
| LED cathode (short leg) | Breadboard B10 | Adjacent column. The LED bridges col 10 ↔ col 11. |
Breadboard C10 | Breadboard − rail | Black jumper. Brings the current out of the LED back toward GND. |
| Breadboard − rail | Arduino GND | Second black jumper. Returns the current to the Arduino. |
The sketch — same Blink as L01-02
We do not need a new sketch today. The original Blink sketch you uploaded in L01-02 toggles pin 13 on and off once a second. As long as your external LED is wired to pin 13, that same code will make it blink.
// The same Blink sketch from ARD-L01-02 — no changes needed.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}LED_BUILTIN is just a built-in name for pin 13. We will dissect every line of this sketch in L01-08. Today, our job is the wiring.
Why it matters
An LED-plus-resistor is the single most common indicator circuit on the planet. Inside your TV remote, your Wi-Fi router, your microwave, your phone charger — every "I am on" light is the circuit you are about to build.
Worked Example 20 min
Build the circuit step by step. Don't power the Arduino on until step 6.
- Plug the resistor in. Push one leg of the 220 Ω resistor into
D6and the other leg intoD11. It lies flat across row D. - Plug the LED in. Put the LED's long leg (anode) into
B11— the same column as the resistor's right leg. Put the short leg (cathode) intoB10. - Add the yellow signal wire. One end into Arduino pin
D13, the other end intoA6on the breadboard. - Add the first black wire. One end into
C10on the breadboard, the other end into any hole on the − rail (top of the breadboard). - Add the second black wire. One end into the − rail, the other end into the Arduino's
GNDpin. - Power up. Plug the Arduino into your laptop with the USB cable. The Blink sketch from L01-02 should already be on the board.
The full wiring diagram
D13, runs up the yellow wire to A6, crosses the 220 Ω resistor in row D to D11, travels up column 11's tie strip to the LED's anode at B11, lights the bulb, exits the cathode at B10, drops out at C10 onto the − rail, and returns through the second black wire to the Arduino's GND pin. Maths: I = (5 − 2) ÷ 220 ≈ 13.6 mA — bright but safe.Expected behaviour
- The onboard
LLED on the Arduino blinks once per second (the same as in L01-02). - Your external red LED blinks in perfect step with it.
- If only the onboard LED blinks but yours does not, your wiring has a problem. Try flipping the LED — that fixes most first-time builds.
Try It Yourself 20 min
Three small experiments on the circuit you just built. No new sketch — just hardware swaps and a maths check.
Goal: Swap the 220 Ω resistor for a 1 kΩ resistor (brown-black-red-gold). The LED still blinks — but does it look brighter, dimmer or the same? Use Ohm's Law to prove what your eyes see.
- Given:
V_pin = 5 V, LED drops≈ 2 V, so the resistor sees3 V.R = 1 000 Ω. - Find:
Iin milliamps - Formula:
I = V ÷ R - Working:
I = ____ ÷ ____ = ____ A = ____ mA - Compared to the 220 Ω value (≈ 13.6 mA), the LED is: brighter / dimmer / same? ____
Goal: Swap the red LED for a green or yellow LED (same wiring, same resistor). Watch how bright it looks. Different colour LEDs "use up" different amounts of voltage. Recalculate the current using each LED's forward voltage from the table.
| LED colour | Forward voltage (VF) | V across the 220 Ω resistor | Current |
|---|---|---|---|
| Red | ~ 2.0 V | 5 − 2.0 = 3.0 V | ≈ 13.6 mA |
| Yellow | ~ 2.1 V | ____ V | ____ mA |
| Green | ~ 3.0 V | ____ V | ____ mA |
- Formula:
I = (V_pin − V_F) ÷ R - Question: Which colour LED draws the least current with this resistor, and why does that match what your eyes see?
Goal: Re-wire the LED so it stays on all the time, instead of blinking — without changing the sketch. (Hint: pin 13 turns on and off because the sketch tells it to. Which Arduino pin is always 5 V?)
- Question: Where would you move the yellow wire to make this happen? ____
- Question: Name one real product that uses an always-on LED like this. ____
Reveal the wiring change
Move the yellow wire from Arduino pin D13 to the Arduino's 5V pin. The 5V pin is always at 5 V the moment the board is powered, so current flows continuously: 5V → resistor → LED → GND. The LED stays on as long as the USB cable is plugged in. Real-world examples: the power LED on a phone charger, the standby light on a TV, the always-on dot next to your router's WPS button.
Mini-Challenge 15 min
The two-rail power indicator
Real makers don't bring 5 V and GND straight from the Arduino pins to every component. They use the breadboard's + rail and − rail as a power bus, then pull side wires off as needed. Today's challenge: rebuild the always-on version of your LED circuit using both rails properly.
Your task:
- Run a red jumper from Arduino
5Vto any hole on the breadboard's top + rail. - Run a black jumper from Arduino
GNDto any hole on the breadboard's top − rail. - Plug your 220 Ω resistor between a hole on the + rail and one of the rows in the top half (e.g.
A20). - Plug your red LED so its anode shares the column with the resistor's right leg, and its cathode goes to a fresh column.
- Run a short black jumper from the LED's cathode column to the − rail.
It works if:
- The LED lights up the instant the USB cable is plugged in.
- Nothing else on the Arduino changes — pin 13's onboard
LLED keeps blinking (because the Blink sketch is still running), but your external LED is steady-on, not blinking. - The wires touching the Arduino are only at
5VandGND— pin 13 is no longer involved.
Reveal one valid wiring answer
D16 to D21. Column 21's tie strip lifts the current to the LED anode at B21; the bulb glows. The cathode at B20 drops out at C20 onto the − rail, which loops back to GND. Maths: I = (5 − 2) ÷ 220 ≈ 13.6 mA — the same brightness as the worked example, but now powered directly from the rails.Recap 5 min
An external LED needs three things to work: a current source (a 5 V pin or any digital pin set HIGH), a current-limiting resistor in series, and the correct polarity (long leg toward the +, short leg toward the −). Wire all three the right way and the bulb lights up. Skip the resistor and the LED dies; flip the polarity and the LED just stays dark.
- LED
- Light-Emitting Diode. A tiny one-way valve that glows when current flows from anode to cathode.
- Anode
- The long leg of an LED. The + side. Current enters here.
- Cathode
- The short leg of an LED, flagged by the flat side of the body. The − side. Current leaves here.
- Forward voltage (VF)
- The voltage an LED "uses up" while lit. Red ≈ 2.0 V, yellow ≈ 2.1 V, green ≈ 3.0 V, blue/white ≈ 3.2 V.
- Current-limiting resistor
- A resistor placed in series with an LED to keep the current at a safe level — typically 220 Ω for 5 V circuits.
- Series
- One-after-the-other. Current has only one path through the components. The opposite is parallel.
Homework 5 min
Rebuild and prove. At home (or in study group), rebuild the lesson's circuit using a different colour LED — green, yellow, blue or white — and the correct resistor for that colour.
- Decide which colour LED you want to use. Look up its forward voltage from the table in the Try-It-Yourself section.
- Using
R = (V_pin − V_F) ÷ I_desiredwithV_pin = 5 VandI_desired = 15 mA, calculate the resistor value you need. - Pick the closest resistor in your kit (220 Ω, 560 Ω, 1 kΩ, 4.7 kΩ or 10 kΩ).
- Write down its 4-band colour code so you can prove you read it (skill from L01-06).
- Wire the circuit. Upload the Blink sketch from L01-02 if needed. Confirm the new LED blinks in step with the onboard LED.
Bring back next class:
- A phone photo of the working circuit with the LED lit.
- Your notebook page showing the maths (
R = ____), the resistor's colour bands, and which LED colour you chose.