import time
from rotary_irq_esp import RotaryIRQ
from machine import Pin
led1 = Pin(4, Pin.OUT)
led2 = Pin(5, Pin.OUT)
sw = Pin(27, Pin.IN, Pin.PULL_UP)
r = RotaryIRQ(pin_num_clk=12,
pin_num_dt=13,
min_val=0,
max_val=5,
reverse=False,
range_mode=RotaryIRQ.RANGE_UNBOUNDED)
val_old = r.value()
while True:
val_new = r.value()
if val_old != val_new:
print('old: ', val_old, 'new: ', val_new)
if val_new < val_old:
print('neu ist kleiner')
led1.on()
led2.off()
elif val_new > val_old:
print('neu ist grösser')
led2.on()
led1.off()
val_old = val_new
print('result =', val_new)
time.sleep_ms(50)
Loading
ssd1306
ssd1306