from machine import Pin, PWM
import utime
led = PWM(Pin(25), 1000) # Using pin 25 and 1000 hz frequency
# Set duty cycle
# This function accept values between 0-65535
# 0 = 0% and 65535 = 100%
# This means each percentage is 65535 / 100 = 655.35
# For 50% it means 655.35 * 50% = 32767.5 rounded to 32768
while True:
for i in range(65535, 0, -6553):
dc = i if i > 6555 else 0
led.duty_u16(dc)
utime.sleep(0.1)
utime.sleep(2)
led.duty_u16(65535)
while True:
pass