micropython-examples/pwm/led.py

16 lines
252 B
Python
Raw Normal View History

2021-06-17 07:52:50 +00:00
from machine import Pin
from machine import PWM
from time import sleep
led = PWM(Pin(0, Pin.OUT))
for i in range(-1, 1024, 8):
led.duty(i)
print(i)
sleep(0.1)
for i in range(1023, -1, -8):
led.duty(i)
print(i)
sleep(0.1)