from machine import PWM,Pin,ADC,I2C,SoftI2C
from pico_i2c_lcd import I2cLcd
import time
i2c =SoftI2C(sda=Pin(14),scl=Pin(13),freq=40000)
lcd_addr = i2c.scan()[0]
lcd =I2cLcd(i2c,lcd_addr,2,16)
adc1=ADC(28)
led= PWM(Pin(0));
led.freq(1000)
# led.duty_u16(65535/2)
x =0
while True:
dcr = adc1.read_u16()
led.duty_u16(dcr)
n =(dcr/65535)*100
time.sleep(1)
lcd.clear()
lcd.move_to(0,0)
lcd.putstr("Duty Cycle =")
lcd.move_to(3,1)
lcd.putstr(str(n)[:4] + "%")