chore(swan_r5):pwmio test
This commit is contained in:
parent
9d27d249cf
commit
88f6bb2cf2
18
ports/stm/boards/swan_r5/tests/pwnio.py
Normal file
18
ports/stm/boards/swan_r5/tests/pwnio.py
Normal file
@ -0,0 +1,18 @@
|
||||
import time
|
||||
import pwmio
|
||||
|
||||
|
||||
def fade(pin):
|
||||
led = pwmio.PWMOut(pin, frequency=5000, duty_cycle=0)
|
||||
# LED setup for QT Py M0:
|
||||
# led = pwmio.PWMOut(board.SCK, 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)
|
||||
|
Loading…
Reference in New Issue
Block a user