import time, math
from machine import Pin, PWM, ADC, I2C, SoftI2C
from pico_i2c_lcd import I2cLcd
i2c = SoftI2C(sda=Pin(26), scl=Pin(21), freq=40000)
lcd_addr = i2c.scan()[0]
lcd=I2cLcd(i2c, lcd_addr, 2, 16)
led=PWM(Pin(0))
led.freq(1000)
x=0
pot = ADC(Pin(28))
while True:
val=pot.read_u16()
volt=round((3.3/65535)*val, 2)
percent=int(val/65535*100)
lcd.move_to(0, 0)
lcd.putstr(str(percent)+"%")
led.duty_u16(percent);
time.sleep(0.6)
lcd.clear()