pimoroni-pico-rp2350/examples/pico_jumbo/big_button.py
Phil Howard af670449c0 CI: Refactor to match our other tooling.
Retarget pimoroni-pico to feature/picovector2-and-layers.
2025-04-14 17:06:58 +01:00

24 lines
624 B
Python

"""
Wire a big arcade button up to GP16 and ground and read the state.
If you have an LED connected to GP15 (with a resistor) and ground the button will turn it on and off.
"""
import machine
import time
button = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_UP)
led_external = machine.Pin(15, machine.Pin.OUT)
while True:
# as we're using a pull up, the logic state is reversed
if button.value() == 0:
print("Button pushed!")
led_external.on()
time.sleep(0.5)
else:
led_external.off()
print("Button not pushed!")
led_external.off()
time.sleep(0.5)