This project turns an LED ON when a button is pressed and OFF when released using MicroPython on the Raspberry Pi Pico W.
- Raspberry Pi Pico W
- MicroPython firmware installed
- Thonny IDE
- Push button + Jumper wires
| Component | Pin | Mode |
|---|---|---|
| Onboard LED | "LED" | OUTPUT |
| Button | GPIO16 | INPUT (PULL-UP) |
- Open Thonny IDE
- Choose Interpreter β MicroPython (Raspberry Pi Pico)
- Connect Pico W via USB
- Copy and save code as
main.py - Press the button and watch the LED respond instantly π
The button input uses a pull-up resistor, keeping it HIGH until pressed.
When pressed β logic LOW β LED turns ON.
When released β logic HIGH β LED turns OFF.
- Add debounce delay:
time.sleep(0.05) - Toggle LED on press (instead of hold)
- Use Wi-Fi to control LED via button press status