import utime
import machine
# Onboard LED (GP25 on Pico / Pico W)
led = machine.Pin("LED", machine.Pin.OUT)
# Push button on GP5, connected to 3.3V
# We enable an internal pull-down resistor:
# Button not pressed -> 0
# Button pressed -> 1
button = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_DOWN)
print("Started testing!")
led.value(1) # LED on while waiting
last_state = 1
while(True):
current_state = button.value()
if (current_state != last_state):
last_state = current_state
if (last_state == 1):
print("pressed")
else:
print("released")