Skip to content

Instantly share code, notes, and snippets.

@shapr
Created May 16, 2022 18:44
Show Gist options
  • Save shapr/792cee78788d6b70bc38081335d3a89a to your computer and use it in GitHub Desktop.
Save shapr/792cee78788d6b70bc38081335d3a89a to your computer and use it in GitHub Desktop.
import time
import board
import pwmio
led = pwmio.PWMOut(board.A1, 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.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment