from machine import Pin, PWM
from utime import sleep
freq = 5000
led = PWM(Pin(21), freq)
IN1 = Pin (5, Pin.OUT)
IN2 = Pin (18,Pin.OUT)
while True:
for duty_cycle in range(0,1024):
IN1.on()
IN2.off()
led.duty(duty_cycle)
sleep(0.005)
for duty_cycle in range(1024,0):
led.duty(duty_cycle)
sleep(0.005)
for duty_cycle in range(0,1024):
IN1.off()
IN2.on()
led.duty(duty_cycle)
sleep(0.005)
for duty_cycle in range(1024,0):
led.duty(duty_cycle)
sleep(0.005)