LED Button Lab
Welcome to the LED Button Lab
An LED button is a button and an LED combined in one part! Press it to turn
on the light — or use code to control the light while the button waits for
your touch. Let's build something amazing!
What Is an LED Button?
An LED button is a push button that has a small LED built into the cap. When the LED is on, the button glows. This makes it easy to see which button is active — perfect for game controllers, status panels, and interactive projects.
The Grove LED Button from Seeed Studio is a popular choice. It has a four-pin Grove connector:
| Pin | Signal |
|---|---|
| 1 | Button signal (HIGH when not pressed, LOW when pressed) |
| 2 | LED signal (HIGH to turn LED on) |
| 3 | GND |
| 4 | VCC (3.3 V) |
You can also use any push button paired with a separate LED — the wiring and code are the same.
Parts You Need
| Part | Quantity | Approximate Cost |
|---|---|---|
| Raspberry Pi Pico | 1 | $4 |
| Grove LED Button (or button + LED) | 1 | $2–$3 |
| Solderless breadboard | 1 | $3 |
| Jumper wires | 4 | — |
| 330 Ω resistor (if using separate LED) | 1 | <$1 |
Wiring Steps
- Connect VCC on the button to 3.3 V (pin 36) on the Pico.
- Connect GND on the button to any GND pin on the Pico.
- Connect the button signal wire to GP14 on the Pico.
- Connect the LED signal wire to GP15 on the Pico.
Watch Out!
If you use a separate LED instead of a Grove button, always put a 330 Ω
resistor in series with the LED. Without a resistor, too much current will
flow and the LED will burn out.
Sample Program: Button Toggles LED
This program turns the LED on when you press the button and off when you press it again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
What Each Line Does
| Line | Purpose |
|---|---|
Pin(14, Pin.IN, Pin.PULL_UP) |
Button input with internal pull-up (reads HIGH when not pressed) |
Pin(15, Pin.OUT) |
LED output pin |
button.value() == 0 |
True when the button is pressed (pulls pin to GND) |
not led_state |
Flips True→False or False→True |
time.sleep(0.3) |
Waits 300 ms so one press = one toggle, not many |
Key Idea
Pin.PULL_UP turns on a tiny resistor inside the Pico that keeps the pin
HIGH when the button is not pressed. When you press the button, it connects
the pin to GND, so the pin goes LOW. That is how the Pico detects a press.
Sample Program: LED Stays On While Button Is Held
This simpler version lights the LED only while you hold the button down:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Monty's Tip
Try connecting the LED to a PWM pin and fading it in slowly when you press
the button. Use PWM(Pin(15)) and duty_u16() to control brightness!
Great Work!
You have wired up an LED button and controlled it two different ways.
Next, try the 7-segment display to show numbers on screen!