import time
import machine
from machine import Pin
time.sleep(0.1) # Wait for USB to become ready
tasteri = [ Pin(i, Pin.IN) for i in range(4) ]
leds = [ Pin(i, Pin.OUT) for i in range(4, 12) ]
count = 0
stanja_tastera = [ taster.value() for taster in tasteri ]
while (True):
if (tasteri[0].value() and not stanja_tastera[0]):
count = (count + 1) % 256
elif (tasteri[1].value() and not stanja_tastera[1]):
count = (count - 1) % 256
elif (tasteri[2].value() and not stanja_tastera[2]):
count = 255
elif (tasteri[3].value() and not stanja_tastera[3]):
count = 0
for i in range(4):
stanja_tastera[i] = tasteri[i].value()
for i in range(8):
leds[i].value((count >> i) & 1)
time.sleep(0.1)