-
Notifications
You must be signed in to change notification settings - Fork 0
GPIO
Notgnoshi edited this page Feb 12, 2016
·
1 revision
This part is pretty easy. In lib/
run build_lib.sh
. This will compile the gpio.so
shared object file and move it to lib/gpiolib/
.
With the directory structure (copy gpiolib/
from lib/
).
parent
├── gpiolib/
│ ├── __init__.py
│ ├── gpio.so
│ └── gpiolib.py
└── test.py
You can do pin IO with the following code in test.py
#!/usr/bin/env python
from gpiolib import *
def main():
sys_init()
pinMode(27, OUTPUT)
pinMode(24, INPUT)
digitalWrite(27, ON)
print(str(digitalRead(24)) # str() converts to string
sys_clean()
if __name__ == '__main__':
main()
You can only read/write to the GPIO/interrupt pins 13-27. Writing to even-numbered pins did not act predictably. However, reading in from even-numbered pins worked just fine.
The pinout is found here and is laid out like this:
^
|
CPU
==========================================================
29..27...................................................1
==========================================================
30..28...................................................2
==========================================================
Also, input_test.py
and output_test.py
do exactly what their names imply. They ask for a pin to test, and will read/write to itself.
This is a custom footer!