import time
from machine import Pin,ADC,PWM,I2C,SoftI2C
from pico_i2c_lcd import I2cLcd
time.sleep(0.1) # Wait for USB to become ready
i2c=SoftI2C(sda=Pin(14),scl=Pin(15),freq=400000)
lcd_address=i2c.scan()[0]
lcd=I2cLcd(i2c,lcd_address,2,16)
vertical=ADC(28)
horizontal=ADC(27)
select=Pin(0,Pin.IN)
i=0
j=0
lcd.clear()
lcd.move_to(i,j)
lcd.putstr(f"O")
while True:
if vertical.read_u16()<32759:
j=(j+1)%2
if vertical.read_u16()>32759:
j=(j-1)%2
if horizontal.read_u16()<32759:
i=(i+1)%16
if horizontal.read_u16()>32759:
i=(i-1)%16
lcd.clear()
lcd.move_to(i,j)
lcd.putstr("O")
time.sleep(0.01)
# while True:
# print(vertical.read_u16())
# time.sleep(0.3)
# print(horizontal.read_u16())
# time.sleep(0.3)
# print(select.value())
# print()
# time.sleep(0.3)