004
Skill Lab
Beginner
Blink the Built-in LED
Make the board prove it is listening by blinking its own tiny light.
Mission: first visible proof
No breadboard yet. No loose wires yet. Your first hardware win uses the LED already built into the Pico 2 W.
You will run one small script, watch the board blink, then change the timing so the blink becomes yours.
Before you run
Check these first:
- Pico 2 W is connected with a data USB cable.
- Thonny is using the MicroPython interpreter for Raspberry Pi Pico.
- No jumper wires are connected to the board.
- You are only using the built-in LED, so there is no circuit to wire yet.
Reminder for future lessons: GPIO pins are 3.3V-safe only. Do not send 5V into GPIO.
Code: blink the built-in LED
from machine import Pin
from time import sleep
led = Pin("LED", Pin.OUT)
while True:
led.toggle()
sleep(0.5)
Run it in Thonny
Paste the code into a new Thonny file. Click Run.
If Thonny asks where to save the file, save it to the Pico or your computer with a clear name like blink_builtin_led.py.
The built-in LED should turn on and off about twice per second. Click Stop when you are done watching it.
What just happened
The line led = Pin("LED", Pin.OUT) creates a handle for the built-in LED and sets it as an output.
Inside the loop, led.toggle() flips the LED to the opposite state. If it was off, it turns on. If it was on, it turns off.
sleep(0.5) pauses the loop so your eyes can see the change.
Debug it
If nothing blinks:
- Check that Thonny is connected to the Pico MicroPython interpreter.
- Check that you used a capital LED inside quotes.
- Click Stop, then Run again.
- Reconnect the board with a known data USB cable.
If you see an error, read the first line that mentions your code. The mistake is usually a missing quote, missing parenthesis, or indentation problem.
Remix: change the heartbeat
Change sleep(0.5) to another number.
- 0.1 makes a fast blink.
- 1 makes a calm blink.
- 2 makes a slow signal.
Run after each change. Stop the script before editing again.
Checkpoint
Mark this complete when:
- The built-in LED blinked from your code.
- You changed the blink speed at least once.
- You can explain what toggle and sleep do in your own words.
Private Dev Log
Write two or three sentences:
1. My blink speed experiment was...
2. One error or almost-error I noticed was...
3. The next thing I want to control is...
References and next step
Reference used for the first LED-control idea:
https://docs.sunfounder.com/projects/pico-2w-kit/en/latest/pyproject/py_led.html
That SunFounder reference uses an external LED circuit. This ObsoleteHQ Week 1 lesson intentionally starts with the Pico 2 W built-in LED so the first code win needs no wiring.