pull/6/head
Philip Howard 13 years ago
parent 567ee0027e
commit 0429f1f342

@ -2,13 +2,15 @@
WiringPi: An implementation of most of the Arduino Wiring WiringPi: An implementation of most of the Arduino Wiring
functions for the Raspberry Pi functions for the Raspberry Pi
WiringPi2: WiringPi version 2 implements new functions for managing IO expanders.
Prerequisites: Prerequisites:
You must have python-dev and python-setuptools installed You must have python-dev and python-setuptools installed
If you manually rebuild the bindings with swig -python wiringpi.i If you manually rebuild the bindings with swig -python wiringpi.i
then cat wiringpi_class.py >> wiringpi.py to get the class-based wrapper then cat wiringpi_class.py >> wiringpi.py to get the class-based wrapper
Get/setup repo: Get/setup repo:
git clone https://github.com/WiringPi/WiringPi-Python.git git clone https://github.com/Gadgetoid/WiringPi2-Python.git
cd WiringPi-Python cd WiringPi-Python
git submodule update --init git submodule update --init
@ -16,21 +18,7 @@ Build & install with:
sudo python setup.py install sudo python setup.py install
Class-based Usage: Class-based Usage:
import wiringpi No classes have been created for this version yet.
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
io.pinMode(1,io.OUTPUT)
io.digitalWrite(1,io.HIGH)
GPIO with /sys/class/gpio (You must first export the interfaces):
import wiringpi
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_SYS)
io.pinMode(1,io.OUTPUT)
io.digitalWrite(1,io.HIGH)
Serial:
serial = wiringpi.Serial('/dev/ttyAMA0',9600)
serial.puts("hello")
serial.close()
Usage: Usage:
import wiringpi import wiringpi
@ -40,6 +28,11 @@ Usage:
OR OR
wiringpi.wiringPiSetupGpio // For GPIO pin numbering wiringpi.wiringPiSetupGpio // For GPIO pin numbering
Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
wiringpi.mcp23017Setup(65,0x20)
wiringpi.pinMode(65,1)
wiringpi.digitalWrite(65,1)
General IO: General IO:
wiringpi.pinMode(1,1) // Set pin 1 to output wiringpi.pinMode(1,1) // Set pin 1 to output
wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1 wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1
@ -54,5 +47,4 @@ Usage:
wiringpi.serialClose(serial) // Pass in ID wiringpi.serialClose(serial) // Pass in ID
Full details at: Full details at:
https://projects.drogon.net/raspberry-pi/wiringpi/ http://www.wiringpi.com

Loading…
Cancel
Save