Skip to content

Commit 98cc3e5

Browse files
committed
document how to test read and write to all GPIO pins
1 parent 2a7e7c6 commit 98cc3e5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
This Python program will open, read and write to all the GPIO pins and the USR LEDs:
2+
```
3+
import Adafruit_BBIO.GPIO as GPIO
4+
import time
5+
6+
for i in range(4):
7+
GPIO.setup("USR%d" % i, GPIO.OUT)
8+
GPIO.output("USR%d" % i, GPIO.HIGH)
9+
GPIO.output("USR%d" % i, GPIO.LOW)
10+
11+
for i in [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,35,36,37,38,39,40,41,42,43,44,45,46]:
12+
GPIO.setup("P8_%d" % i, GPIO.OUT)
13+
GPIO.output("P8_%d" % i, GPIO.HIGH)
14+
GPIO.output("P8_%d" % i, GPIO.LOW)
15+
16+
for i in [11,12,13,14,15,16,17,18,21,22,23,24,25,26,27,28,29,30,31,41,42]:
17+
GPIO.setup("P9_%d" % i, GPIO.OUT)
18+
GPIO.output("P9_%d" % i, GPIO.HIGH)
19+
GPIO.output("P9_%d" % i, GPIO.LOW)
20+
```
21+
22+
This can be useful when run with strace to verify that the library is operating as expected:
23+
```
24+
sudo strace -e file python ~/gpio_output_test.py 2>&1 |grep '/sys/'|less
25+
```
26+
27+
refer to this gist for more info:
28+
https://gist.github.com/pdp7/e7753faff9a9bd27389a0173c71f9312

0 commit comments

Comments
 (0)