from machine import Pin
from time import sleep
led0 = Pin(2, Pin.OUT)
led1 = Pin(0, Pin.OUT)
led2 = Pin(4, Pin.OUT)
led3 = Pin(16, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_UP)
count = 0
def isr(pin):
global count
count += 1
button.irq(trigger=Pin.IRQ_FALLING, handler=isr)
def bitRead(value, bit):
return (value >> bit) & 1
while True:
led0.value(bitRead(count, 0))
led1.value(bitRead(count, 1))
led2.value(bitRead(count, 2))
led3.value(bitRead(count, 3))
sleep(0.3)