Skip to content

Instantly share code, notes, and snippets.

@simonprickett
Created June 20, 2025 21:07
Show Gist options
  • Save simonprickett/3d0e8d989725e64a38426c0320a021e7 to your computer and use it in GitHub Desktop.
Save simonprickett/3d0e8d989725e64a38426c0320a021e7 to your computer and use it in GitHub Desktop.
import board
import pwmio
import time
gauge1 = pwmio.PWMOut(board.GP22, frequency=1000)
gauge2 = pwmio.PWMOut(board.GP26, frequency=1000)
gauge3 = pwmio.PWMOut(board.GP16, frequency=1000)
ds1 = 0
delta1 = 1000
ds2 = 65000
delta2 = -1000
while True:
gauge1.duty_cycle = ds1
gauge2.duty_cycle = ds2
gauge3.duty_cycle = ds1
ds1 = ds1 + delta1
ds2 = ds2 + delta2
if ds1 >= 65000:
delta1 = -1000
if ds1 <= 0:
delta1 = 1000
if ds2 >= 65000:
delta2 = -1000
if ds2 <= 0:
delta2 = 1000
time.sleep(0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment