You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. Below are some examples.
38
34
39
-
**GPIO Setup**
35
+
### GPIO Setup
40
36
41
37
Import the library, and setup as GPIO.OUT or GPIO.IN::
42
38
@@ -47,15 +43,15 @@ You can also refer to the pin names::
47
43
48
44
GPIO.setup("GPIO0_26", GPIO.OUT)
49
45
50
-
**GPIO Output**
46
+
### GPIO Output
51
47
52
48
Setup the pin for output, and write GPIO.HIGH or GPIO.LOW. Or you can use 1 or 0.::
53
49
54
50
import Adafruit_BBIO.GPIO as GPIO
55
51
GPIO.setup("P8_14", GPIO.OUT)
56
52
GPIO.output("P8_14", GPIO.HIGH)
57
53
58
-
**On-Board LEDs**
54
+
### On-Board LEDs
59
55
60
56
On-board LEDs (USR0-USR3) are handled by LED class driver rather than the GPIO pin driver.
61
57
@@ -77,37 +73,38 @@ Setup the pin for output and write GPIO.HIGH or GPIO.LOW::
77
73
GPIO.output("USR%d" % i, GPIO.LOW)
78
74
time.sleep(1)
79
75
80
-
**GPIO Input**
76
+
### GPIO Input
81
77
82
-
Inputs work similarly to outputs.::
78
+
Inputs work similarly to outputs.:
83
79
84
80
import Adafruit_BBIO.GPIO as GPIO
85
81
GPIO.setup("P8_14", GPIO.IN)
86
82
87
-
Polling inputs::
83
+
Polling inputs:
88
84
89
85
if GPIO.input("P8_14"):
90
86
print("HIGH")
91
87
else:
92
88
print("LOW")
93
89
94
-
Waiting for an edge (GPIO.RISING, GPIO.FALLING, or GPIO.BOTH::
90
+
Waiting for an edge (GPIO.RISING, GPIO.FALLING, or GPIO.BOTH:
95
91
96
92
GPIO.wait_for_edge(channel, GPIO.RISING)
97
93
98
94
or
99
95
100
96
GPIO.wait_for_edge(channel, GPIO.RISING, timeout)
101
97
102
-
Detecting events::
98
+
Detecting events:
103
99
104
100
GPIO.add_event_detect("P9_12", GPIO.FALLING)
105
101
#your amazing code here
106
102
#detect wherever:
107
103
if GPIO.event_detected("P9_12"):
108
104
print "event detected!"
109
105
110
-
**PWM**::
106
+
### PWM
107
+
**The PWM Duty Cycle range was reversed in 0.0.15 from 100(off)-0(on) to 0(off)-100(on). Please update your code accordingly.**
111
108
112
109
import Adafruit_BBIO.PWM as PWM
113
110
#PWM.start(channel, duty, freq=2000, polarity=0)
@@ -122,7 +119,7 @@ Detecting events::
122
119
#set polarity to 1 on start:
123
120
PWM.start("P9_14", 50, 2000, 1)
124
121
125
-
**ADC**::
122
+
### ADC:
126
123
127
124
import Adafruit_BBIO.ADC as ADC
128
125
ADC.setup()
@@ -133,23 +130,20 @@ Detecting events::
133
130
#read_raw returns non-normalized value
134
131
value = ADC.read_raw("P9_40")
135
132
136
-
**Running tests**
133
+
## Running tests
137
134
138
-
Install py.test to run the tests. You'll also need the python compiler package for py.test.::
135
+
Install py.test to run the tests. You'll also need the python compiler package for pytest:
139
136
140
-
opkg update && opkg install python-compiler
141
-
#Either pip or easy_install
142
137
pip install -U pytest
143
-
easy_install -U pytest
144
138
145
-
Execute the following in the root of the project::
139
+
Execute the following in the root of the project:
146
140
147
-
py.test
141
+
pytest
148
142
149
-
**Credits**
143
+
## Credits
150
144
151
145
The BeagleBone IO Python library was originally forked from the excellent MIT Licensed [RPi.GPIO](https://code.google.com/p/raspberry-gpio-python) library written by Ben Croston.
152
146
153
-
**License**
147
+
## License
154
148
155
149
Written by Justin Cooper, Adafruit Industries. BeagleBone IO Python library is released under the MIT License.
0 commit comments