Created
July 3, 2025 12:16
-
-
Save simonprickett/bd32119e7d7c74a0d7abe175848f3f11 to your computer and use it in GitHub Desktop.
CircuitPython script to control 3 x 3v panel gauges 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 board | |
import pwmio | |
import time | |
# Assumes a Raspberry Pi Pico 2 W, with gauges connected | |
# to GP22 / Pin 29, GP26 / Pin 31 and GP16 / Pin 21 and ground. | |
# You can use a single ground pin on the Pico and chain the | |
# ground connections across the three meters. | |
# Sweeps the gauges back and forth on a continuous timer. | |
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