#https://drive.google.com/file/d/1We_Cn3q8TFCLi9N-0TeaBm5BTY-8fwUG/view
from machine import PWM, Pin, ADC, SoftI2C, I2C
import time
from pico_i2c_lcd import I2cLcd
import utime
i2c=SoftI2C(sda=Pin(26),scl=Pin(21),freq=400000)
lcd_addr=i2c.scan()[0]
lcd=I2cLcd(i2c,lcd_addr,4,20)
xAxis = ADC(Pin(27))
yAxis = ADC(Pin(28))
button = Pin(3,Pin.IN, Pin.PULL_UP)
while True:
xValue = xAxis.read_u16()
yValue = yAxis.read_u16()
buttonValue = button.value()
xStatus = "middle"
yStatus = "middle"
lcd.move_to(8,1)
lcd.putstr("HI")
buttonStatus = "not pressed"
if xValue <= 600:
xStatus = "right"
lcd.clear()
lcd.move_to(19,1)
lcd.putstr("HI")
elif xValue >= 60000:
xStatus = "left"
lcd.clear()
lcd.move_to(0,1)
lcd.putstr("HI")
if yValue <= 600:
yStatus = "top"
lcd.clear()
lcd.move_to(8,0)
lcd.putstr("HI")
elif yValue >= 60000:
yStatus = "down"
lcd.clear()
lcd.move_to(8,2)
lcd.putstr("HI")
if buttonValue == 0:
buttonStatus = "pressed"
print("X: " + xStatus + ", Y: " + yStatus + " -- button " + buttonStatus)
utime.sleep(0.1)