Created
July 3, 2025 12:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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