Raspberry Pi Pico First Steps: LED Blink and Button Control

Wed May 06 2026

Got excited about a Raspberry Pi Pico starter kit. Started with LED blink, then added button control and learned about pull-up resistors.

Written by: Cesar

2 min read

Raspberry Pi

Pico

MicroPython

Hardware

DIY

All this Shelly business got me excited about playing with a Raspberry Pi Pico starter kit I purchased a while back.

I decided to fire up the old Thonny IDE and try the simple hello world example: blinking the on-board LED on GPIO25.

from machine import Pin
import utime

led_onboard = Pin(25, Pin.OUT)
while True:
    led_onboard.value(1)
    utime.sleep(1)
    led_onboard.value(0)
    utime.sleep(1)

Works perfectly. LED blinks on, off, on, off. Dead simple.

Next: Add a Button

Then I decided to connect a physical button and make it control the LED:

from machine import Pin
import time

led = Pin(25, Pin.OUT)  
button = Pin(14, Pin.IN, Pin.PULL_UP)

while True:
    if button.value() == 0:
        print("Pressed!")
        led.toggle()
    else:
        print("Released")
    time.sleep(0.5)

All was going pretty well. This also worked on the first try — button press toggles the LED.

Pull-Up Resistors (The “Aha” Moment)

Then I looked at what a pull-up resistor actually does. This is where things clicked.

Without a pull-up resistor: the pin floats. It has no definite voltage reading. Is it high? Is it low? Unstable. Unreliable.

With a pull-up resistor: the reading is stable. The pin reads as 1 (HIGH) by default. When you ground it (press the button), it reads as 0 (LOW). Clear signal. No noise.

That’s why the code uses Pin.PULL_UP — it tells the Pico to use the internal pull-up resistor so the button press is clean and reliable.

What’s Next

Then I started on another small project and that’s when things got interesting.

More to come.


Why this matters: From Shelly smart switches to Raspberry Pi Pico microcontrollers, the fundamentals are the same: GPIO pins, voltage logic, button debouncing, state management. Once you understand one, the others make sense fast.