-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_pins.py
executable file
·34 lines (26 loc) · 811 Bytes
/
test_pins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
#
# Light up GPIO pins. Useful for figuring out how a prototype is wired
# after assembly.
#
import RPi.GPIO as GPIO
all_pins = [ 17, 27, 22, 5, 6, 13, 23, 24, 25, 12, 4 ]
GPIO.setmode( GPIO.BCM )
GPIO.setup( all_pins, GPIO.OUT, initial=GPIO.LOW )
last_pin = None
try:
while True:
pin_num = int(raw_input("What pin would you like to activate? "))
if pin_num not in all_pins:
print "That is not a valid pin number."
continue
if last_pin is not None:
print "Bringing pin %d low..." % last_pin
GPIO.output(last_pin, GPIO.LOW)
print "Bringing pin %d high..." % pin_num
GPIO.output(pin_num, GPIO.HIGH)
last_pin = pin_num
except:
print "Cleaning up!"
GPIO.cleanup()
raise