You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

WiringPi: An implementation of most of the Arduino Wiring
functions for the Raspberry Pi
WiringPi2: WiringPi version 2 implements new functions for managing IO expanders.
Prerequisites:
You must have python-dev and python-setuptools installed
If you manually rebuild the bindings with swig -python wiringpi.i
then cat wiringpi_class.py >> wiringpi.py to get the class-based wrapper
Get/setup repo:
git clone https://github.com/Gadgetoid/WiringPi2-Python.git
cd WiringPi2-Python
Build & install with:
sudo python setup.py install
Or Python 3
sudo python3 setup.py install
Class-based Usage:
No classes have been created for this version yet.
Usage:
import wiringpi
wiringpi.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
OR
wiringpi.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
OR
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:
wiringpi.pinMode(1,1) // Set pin 1 to output
wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1
wiringpi.digitalRead(1) // Read pin 1
Bit shifting:
wiringpi.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
Serial:
serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
wiringpi.serialPuts(serial,"hello")
wiringpi.serialClose(serial) // Pass in ID
Full details at:
http://www.wiringpi.com