# Programmer: Aula
from machine import Pin, PWM, ADC
from time import sleep
# creating PWM and ADC objects
adc = machine.ADC(28)
pwm0 = PWM(Pin(0))
Led = PWM(Pin(2))
IN1 = Pin(1, Pin.OUT)
# setting frequency of PWM output
pwm0.freq(50)
Led.freq(50)
# continuously control the brightness of the LED using the potentiometer
while True:
# reading analog values from the potentiometer
digital_value = adc.read_u16()
pwm0.duty_u16(digital_value) # set duty cycle, range 0-65535
IN1.low()
# writing analog values to the LED
Led.duty_u16(digital_value)
print(digital_value)
sleep(1)