Skip to content

Commit a4d2e53

Browse files
committed
Allow user to select pin
1 parent 347fddb commit a4d2e53

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

pcb/hardware_tests/fan_gpio.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import RPi.GPIO as GPIO
22
import time
33

4-
pin = 24
5-
# Scope fan = 5, cam fan 1 = 23, cam fan 2 = 24
4+
pin = int(input("Enter pin: "))
5+
valid_pins = {
6+
'scope fan': 5,
7+
'cam fan 1': 23,
8+
'cam fan 2': 24,
9+
}
10+
if pin not in valid_pins.values:
11+
raise ValueError(f"Invalid pin, expected one of {valid_pins}")
612

713
GPIO.setmode(GPIO.BCM)
814
GPIO.setwarnings(False)

pcb/hardware_tests/limit_switch_gpio.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import RPi.GPIO as GPIO
22
import time
33

4-
ls1 = 18
5-
# LS1 = 18, LS2 = 15
4+
pin = int(input("Enter pin: "))
5+
valid_pins = {
6+
'LS1': 18,
7+
'LS2': 15,
8+
}
9+
if pin not in valid_pins.values:
10+
raise ValueError(f"Invalid pin, expected one of {valid_pins}")
611

712

813
GPIO.setmode(GPIO.BCM)
914
GPIO.setwarnings(False)
10-
GPIO.setup(ls1, GPIO.IN,pull_up_down=GPIO.PUD_UP)
15+
GPIO.setup(pin, GPIO.IN,pull_up_down=GPIO.PUD_UP)
1116

1217
try:
1318
while True:
14-
if not GPIO.input(ls1):
19+
if not GPIO.input(pin):
1520
print("Pressed")
1621
time.sleep(0.25)
1722
except KeyboardInterrupt:

0 commit comments

Comments
 (0)