from machine import Pin, I2C, ADC, Timer
from pico_i2c_lcd import I2cLcd
sda = Pin(0)
scl = Pin(1)
i2c = I2C(0, sda=sda, scl=scl, freq=40000)
devices = i2c.scan()
if len(devices) <= 0:
print("No devices found!")
else:
print(hex(devices[0]))
i2c_addr = devices[0]
lcd = I2cLcd(i2c, i2c_addr, 2, 16)
adc = ADC(0)
def fn(timer):
lcd.clear()
raw_value = adc.read_u16()
angle = raw_value / 65535 * 90
lcd.putstr(str(angle))
timer = Timer(freq=1, mode=Timer.PERIODIC, callback=fn)