Adafruit_Learning_System_Gu.../CircuitPython_Quick_Starts/CircuitPython_PWM/code.py
2021-08-18 13:03:59 -04:00

15 lines
363 B
Python

import time
import board
import pwmio
led = pwmio.PWMOut(board.D13, frequency=5000, duty_cycle=0)
while True:
for i in range(100):
# PWM LED up and down
if i < 50:
led.duty_cycle = int(i * 2 * 65535 / 100) # Up
else:
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down
time.sleep(0.01)