Created
May 16, 2022 18:44
-
-
Save shapr/792cee78788d6b70bc38081335d3a89a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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