#analog and lcd
import time
from machine import I2C,SoftI2C,Pin,Timer,ADC
from pico_i2c_lcd import I2cLcd
i2c = SoftI2C(sda=Pin(0),scl= Pin(1), freq = 400000)
devices = i2c.scan()
addr = devices[0]
lcd = I2cLcd(i2c,addr,2,16)
hori_axis = ADC(28)
ver_axis = ADC(27)
while True:
h_status = hori_axis.read_u16()
v_status = ver_axis.read_u16()
print("h_status:",h_status)
print("v_status:",v_status)
print()
if h_status==32759 and v_status==32759:
lcd.putstr("Center")
time.sleep(2)
lcd.clear()
if h_status==32759 and v_status==0:
lcd.putstr("Down")
time.sleep(2)
lcd.clear()
if h_status==32759 and v_status==65535:
lcd.putstr("UP")
time.sleep(2)
lcd.clear()
if h_status==0 and v_status==32759:
lcd.putstr("Right")
time.sleep(2)
lcd.clear()
if h_status==65535 and v_status==32759:
lcd.putstr("Left")
time.sleep(2)
lcd.clear()