Skip to content

Instantly share code, notes, and snippets.

@seanburlington
Created December 24, 2023 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanburlington/582e16444659e67165eb1a7101ef1e74 to your computer and use it in GitHub Desktop.
Save seanburlington/582e16444659e67165eb1a7101ef1e74 to your computer and use it in GitHub Desktop.
from machine import Pin, PWM
import time
# Set up LED pins
seg1 = Pin(13, Pin.OUT)
seg2 = Pin(12, Pin.OUT)
seg3 = Pin(11, Pin.OUT)
seg4 = Pin(10, Pin.OUT)
seg5 = Pin(9, Pin.OUT)
duty_cycle = 100
# Create a list of our LEDs
segments = [PWM(seg1), PWM(seg2), PWM(seg3), PWM(seg4), PWM(seg5)]
frequency = 5000
for led in segments:
led.freq (frequency)
power = [
[65536, 1400, 0, 0, 0],
[1400, 65536, 0, 0, 0],
[400, 1400, 65536, 0, 0],
[0, 400, 1400, 65536, 0],
[0, 0, 400, 1400, 65536],
[0, 0, 0, 65536, 1400],
[0, 0, 65536, 1400, 400],
[0, 65536, 1400, 400, 0],
[65536, 1400, 400, 0, 0],
]
pause=0.2
try:
while True:
for seq in power:
for i in range(5):
segments[i].duty_u16(seq[i])
time.sleep(pause)
except KeyboardInterrupt:
print("Keyboard interrupt")
for led in segments:
led.duty_u16(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment