File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 11import RPi .GPIO as GPIO
22import 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
713GPIO .setmode (GPIO .BCM )
814GPIO .setwarnings (False )
Original file line number Diff line number Diff line change 11import RPi .GPIO as GPIO
22import 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
813GPIO .setmode (GPIO .BCM )
914GPIO .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
1217try :
1318 while True :
14- if not GPIO .input (ls1 ):
19+ if not GPIO .input (pin ):
1520 print ("Pressed" )
1621 time .sleep (0.25 )
1722except KeyboardInterrupt :
You can’t perform that action at this time.
0 commit comments