Here's how to get GPIO working in Python on the Orange Pi One.
Note. The GPIO pins on the Orange Pi One are flipped 180 degrees compared to the Orange Pi PC version or a Raspberry Pi!
check out my other Orange Pi tutorials:
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Download and Install Python Library
To start you will need the python headers and library installed, if you haven't or aren't sure just type:
sudo apt-get install python-dev
Then download the pyH3 library from:
extract the folder and place in '/home/pi'
from the terminal go into that directory:
then install it using:
python setup.py install
The library is now installed.
Step 2: Test It!
The way the pins are referred to are slightly different to a Raspberry Pi, they are named "ports" & "connectors".
UPDATE 03/05/2016: The new armbian images no longer export the gpios to /gpio_sw. See the above image for the port names. Image Credit: http://forum.armbian.com/index.php/topic/759-tutor...
For example pin 29 (BCM05) is port 'PA7'
To test, connect an LED to pin 29 through a 300ohm resistor then to the ground. (see diagram below)
and created a file called 'test.py':
#import the library from pyA20.gpio import gpio from pyA20.gpio import port from time import sleep #initialize the gpio module gpio.init() #setup the port (same as raspberry pi's gpio.setup() function) gpio.setcfg(port.PA7, gpio.OUTPUT) #now we do something (light up the LED) gpio.output(port.PA7, gpio.HIGH) #turn off the LED after 2 seconds sleep(2) gpio.output(port.PA7, gpio.LOW)
Dont forget to make your test file executable:
chmod +x test.py
and run as root:
sudo su ./test.py
Step 3: .
That's the basics working, more advanced stuff like i2C should work aswell but I haven't tested.
Credit goes to: Duxingkei Chow and Stefan Mavrodiev (examples in git repository)
1 Person Made This Project!
srg tulyakov made it!