Skip to content

Commit 88f6bb2

Browse files
committed
chore(swan_r5):pwmio test
1 parent 9d27d24 commit 88f6bb2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import time
2+
import pwmio
3+
4+
5+
def fade(pin):
6+
led = pwmio.PWMOut(pin, frequency=5000, duty_cycle=0)
7+
# LED setup for QT Py M0:
8+
# led = pwmio.PWMOut(board.SCK, frequency=5000, duty_cycle=0)
9+
10+
while True:
11+
for i in range(100):
12+
# PWM LED up and down
13+
if i < 50:
14+
led.duty_cycle = int(i * 2 * 65535 / 100) # Up
15+
else:
16+
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down
17+
time.sleep(0.01)
18+

0 commit comments

Comments
 (0)