#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)
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS