from machine import Pin
from time import sleep
# Setup pins for buttons and LEDs
Button1 = Pin(1, Pin.IN, Pin.PULL_UP)
LED1 = Pin(2, Pin.OUT)
Button2 = Pin(3, Pin.IN, Pin.PULL_UP)
LED2 = Pin(7, Pin.OUT)
n = 0
while True:
a = Button1.value()
b = Button2.value()
if a == 0:
n += 1
print(n)
LED1.value(1)
sleep(0.3)
else:
LED1.value(0)
if b == 0:
n -= 1
print(n)
LED2.value(1)
sleep(0.3)
else:
LED2.value(0)
sleep(0.05)