Skip to content

Instantly share code, notes, and snippets.

@simonprickett
Created July 3, 2025 12:07
Show Gist options
  • Save simonprickett/f7ccff18563b52d6769c5aff07e2b4e7 to your computer and use it in GitHub Desktop.
Save simonprickett/f7ccff18563b52d6769c5aff07e2b4e7 to your computer and use it in GitHub Desktop.
CircuitPython script to control a 3v panel gauge from a Raspberry Pi Pico 2W
import pwmio
import time
# Assumes a Raspberry Pi Pico 2 W, with gauge connected
# to GP22 / Pin 29 and ground. Sweeps the gauge back and
# forth on a continuous timer.
gauge = pwmio.PWMOut(board.GP22, frequency=1000)
ds = 0
delta = 1000
while True:
print(ds)
gauge.duty_cycle = ds
ds = ds + delta
if ds >= 65000:
delta = -1000
if ds <= 0:
delta = 1000
time.sleep(0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment