PyRasp

← All practice problems

Raspberry Pi Pico practice problem · Raspberry Pi Pico

Button mirror

EasyBudget $4MicroPython

A push button is wired from GP12 to 3V3, with a red LED on GP13.

Make the LED a mirror of the button: lit while the button is held, dark otherwise. The pin needs a pull-down so it reads 0 when nothing is pressed:

button = Pin(12, Pin.IN, Pin.PULL_DOWN)

More in Raspberry Pi Pico