from machine import Pin, PWM
from time import sleep_ms
LED = 25 # For ESP32
pin_digital = Pin(LED, mode=Pin.OUT)
pwm_led = PWM(pin_digital) # Attach PWM object on the LED pin
# Settings
pwm_led.freq(1_000) #Hz
while True:
for duty in range(0,101):
d_registre = int((duty/100)*1023)
print("Duty =", duty, "%", "Duty_registre =", d_registre )
pwm_led.duty(d_registre) # For ESP32
sleep_ms(500)