from time import sleep_ms, ticks_ms
from machine import I2C, Pin
from i2c_lcd import I2cLcd
DEFAULT_I2C_ADDR = 0x27
up_ijo=Pin(15,Pin.IN,Pin.PULL_UP) #Build the KEY object
down_kuning=Pin(2,Pin.IN,Pin.PULL_UP)
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=400000)
lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
lcd.clear()
lcd.putstr('Example #3')
sleep_ms(1000)
count = 0
lcd.move_to(0,1)
lcd.putstr('Counter: {}'.format(count))
while True:
if up_ijo.value()==0:
count=count+1
lcd.move_to(9,1)
lcd.putstr(' ')
lcd.move_to(9,1)
lcd.putstr('{}'.format(count))
sleep_ms(500)
if down_kuning.value()==0:
count=count-1
lcd.move_to(9,1)
lcd.putstr(' ')
lcd.move_to(9,1)
lcd.putstr('{}'.format(count))
sleep_ms(500)