Skip to content

Instantly share code, notes, and snippets.

@codepope
Last active November 19, 2019 12:57
Show Gist options
  • Save codepope/2609387869c4c8d2e16219c722d8d53e to your computer and use it in GitHub Desktop.
Save codepope/2609387869c4c8d2e16219c722d8d53e to your computer and use it in GitHub Desktop.
Pulses the Serpente's single RGB LED through various colours
import time
import board
import pulseio
ledr = pulseio.PWMOut(board.LED_R, frequency=5000, duty_cycle=0)
ledg = pulseio.PWMOut(board.LED_G, frequency=5000, duty_cycle=0)
ledb = pulseio.PWMOut(board.LED_B, frequency=5000, duty_cycle=0)
leds=[ ledr, ledg, ledb ]
while True:
for led in leds:
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)
led.duty_cycle=65535
@codepope
Copy link
Author

Refreshed for a better cycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment