Вы находитесь на странице: 1из 3

technology workshop craft home food play outside costumes

Orange Pi One Python GPIO (basic)


by DuncanW10 on February 27, 2016

Table of Contents

Orange Pi One Python GPIO (basic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Orange Pi One Python GPIO (basic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Download and install python library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Test It! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

http://www.instructables.com/id/Orange-Pi-One-Python-GPIO-basic/
Intro: Orange Pi One Python GPIO (basic)
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!

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:

https://github.com/duxingkei33/orangepi_PC_gpio_pyH3

extract the folder and place in '/home/pi'

from the terminal go into that directory:


cd orangepi_PC_gpio_pyH3

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".

To view on your One, type:


gpio readall

This will show you the layout and names for each "port".

for example pin 29 (BCM05) is port 'PA7'

To test, connect an LED to pin 29 through a 300ohm resistor then to the ground.

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

http://www.instructables.com/id/Orange-Pi-One-Python-GPIO-basic/
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)

Related Instructables

Raspberry Pi
Build Your First Easy Project - How to Make Halloween Raspberry PI
IOT with a Control an LED Your First Lights and L298N Dual H Raspberry Pi:
Raspberry Pi, Light with Simple Led Music Show by Bridge DC Python
DHT11 sensor, Python Using a Blink Project in noelportugal scripting the
Motor by kenm5
and Raspberry Pi by Raspberry Pi2 GPIO by
Thingspeak. by NoobT by VIVEK GR scottkildall
SolderingSunday

Advertisements

Comments

http://www.instructables.com/id/Orange-Pi-One-Python-GPIO-basic/

Вам также может понравиться