from machine import Pin, PWM #improting module to get pin function and pulse width modulation
from time import sleep #importing module to get sleep function
frequency = 5000 #setting frequency
led = PWM(Pin (13), frequency) #defining led pin and setting it up for PWM
while True:
for dutyCycle in range(0, 1023, 200): #varrying the values of brightness
led.duty(dutyCycle) #dutycycle = {time on} / {total time of a cycle}
sleep(0.5)
for dutyCycle in range(1023, 0, -200): #varrying the values of brightness
led.duty(dutyCycle) #dutycycle = {time on} / {total time of a cycle}
sleep(0.5)