"""Program 11-1: Using PWM to modulate the brightness of the LED""" import time from machine import Pin, PWM pwm = PWM(Pin(25)) # onboard LED pwm.freq(500) while True: # Stepping up the duty cycle for i in range(0, 65535, 500): pwm.duty_u16(i) time.sleep(0.02) # Stepping down the duty cycle for i in range(65535, 0, -500): pwm.duty_u16(i) time.sleep(0.02)