pinGPT logo
Chapter E: External LED6/8
Chapter D

Chapter E

Blink an External LED 💡

Learn how to wire real electronic components to your board. Control an electronic output and discover the magic of plugging objects into GPIO pins.

[ External LED + resistor wired to a GPIO pin ]

1. The parts you need

Grab one 5mm LED, one 220Ω resistor, and two jumper wires. The resistor protects the LED from too much current.

2. Wire it up

Connect the long leg of the LED (the +) to GPIO 5 through the resistor. Connect the short leg (the −) to a GND pin on your pinGPT.

[ Wiring diagram: GPIO 5 → resistor → LED → GND ]

3. Run the blink program

python
from machine import Pin
from time import sleep

led = Pin(5, Pin.OUT)   # connected to GPIO 5

while True:
    led.value(1)
    sleep(0.5)
    led.value(0)
    sleep(0.5)

Your external LED should blink on/off every half second — exactly the same idea as the onboard LED, but on a component you wired yourself.

What just happened

You just made the leap from the board to the real world. Any GPIO pin can drive an output: LEDs, buzzers, relays, motors (with a driver). The pattern is always the same — Pin.OUT, then .value(1) or .value(0).