from time import sleep
from digitalio import DigitalInOut, Direction, Pull
import board
led = DigitalInOut(board.GP22)
led.direction = Direction.OUTPUT
btn = DigitalInOut(board.GP19)
btn.direction = Direction.INPUT
btn.pull = Pull.UP
prev_state = btn.value
mode = 0
while True:
cur_state = btn.value
if cur_state != prev_state:
if not cur_state:
print("BTN is down")
mode +=1
print(mode)
if mode == 8:
mode =0
prev_state = cur_state