1. Switch a pin
You will be able to
- make any header pin high (3.3 V) or low (0 V),
- light an LED through a resistor without damaging it,
- explain why a pin is called an output.
You need: the Pico, one LED, one 330 Ω resistor. Problem: First blink.
The idea
A GPIO pin is a tiny switch connected to the inside of the chip. When it is an output, the chip drives it:

“High” does not mean more electricity. It means 3.3 volts relative to ground. Current flows from 3.3 V, through the resistor and the LED, to ground (0 V).
The resistor is not decoration. An LED with no resistor tries to take far more current than the pin can give; the resistor sets a safe, sensible current (about 5 mA here).
The exact tools
| What | MicroPython |
|---|---|
| Make a pin an output | Pin(13, Pin.OUT) |
| High / low | led.on(), led.off(), led.value(1) |
| Flip it | led.toggle() |
| Read back an output | led.value() |
| The on-board LED | Pin(25, Pin.OUT) — GP25, not on the header |
On this Pico, Pin(13) is GP13, the pin labelled GP13 on header position P17.
Build it
Wire the LED from GP13, through the 330 Ω resistor, to GND. In main.py:
from machine import Pin
import utime
led = Pin(13, Pin.OUT)
led.on()
utime.sleep(1)
led.off()
utime.sleep(1)
led.on()
Press Run. Then change the last line to led.off() and run again.
Fun fact. A red LED needs about 1.8 V to light. The Pico gives 3.3 V, so the resistor takes the extra 1.5 V. That is why the same LED on a 5 V board needs a bigger resistor.
What you should see
The LED comes on for one second, goes off for one second, then comes on and stays on. The console shows nothing — this program has nothing to say yet.
Common mistakes
| What you see | Why | Fix |
|---|---|---|
| Nothing lights | The LED is backwards | The longer leg (anode) goes to the resistor/GP13, the flat side to GND |
| Nothing lights | The resistor is in the wrong place | GP13 → resistor → LED → GND, in that order |
| The LED is dim | A very large resistor | 220–330 Ω is right for a 3.3 V board |
NameError: name 'Pin' is not defined | The import is missing | from machine import Pin |
| A warning about current | No resistor, or a short | Add the resistor; never wire GP13 straight to GND |
Check yourself
- What voltage is on GP13 when it is low?
- Why does the LED need a resistor?
- What does
Pin(25)control, and where is it?
Answers: 0 V · to limit the current · the on-board LED, not a header pin.
Remember
Pin(n, Pin.OUT)makes a pin an output;on(),off()andtoggle()drive it.- High = 3.3 V, low = 0 V; current needs a path to ground.
- Always use a resistor with an LED.
Go further
- Make the on-board LED blink with
Pin(25)— problem The Pico's own LED. - Make two LEDs take turns — Alternating lights.
- Try
led.value(1)andled.value(0)instead ofon()/off(). They are the same thing.