import machine
from machine import ADC, Pin, I2C, PWM
from time import sleep
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
config_lcd = I2C (scl = Pin (22), sda = Pin (21), freq = 400000)
config_pot = ADC (Pin (33))
config_ser = PWM (Pin (4), freq = 50)
LCD = I2cLcd (config_lcd, 0x27, 2, 16)
for x in "Bom dia!":
LCD.putstr (x)
sleep (0.3)
LCD.move_to (0, 1)
for x in "Burning Goose!":
LCD.putstr (x)
sleep (0.05)
LCD.clear ()
min_duty = 25
max_duty = 125
def uptade_ser_in_lcd():
receive_pot = config_pot.read ()
angle = int (receive_pot / (4095/180))
duty = int ( (angle / 180) * (max_duty - min_duty) + min_duty)
config_ser.duty (duty)
LCD.move_to (3, 0)
LCD.putstr ('{num:0{width}}'.format (num = angle, width = 3) + " graus")
sleep (0.1)
while True:
uptade_ser_in_lcd()