From 88f6bb2cf2e176c26b256c8acfdf9df7c858c103 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 28 Sep 2021 07:06:52 -0700 Subject: [PATCH] chore(swan_r5):pwmio test --- ports/stm/boards/swan_r5/tests/pwnio.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ports/stm/boards/swan_r5/tests/pwnio.py diff --git a/ports/stm/boards/swan_r5/tests/pwnio.py b/ports/stm/boards/swan_r5/tests/pwnio.py new file mode 100644 index 0000000000..d1e67e7631 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/pwnio.py @@ -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) +