blob: 3761604aa0704e8366641b3128428f3810390a2c [file] [log] [blame]
Philip Howard567ee002013-03-27 22:22:00 +00001
2WiringPi: An implementation of most of the Arduino Wiring
3 functions for the Raspberry Pi
4
Philip Howard0429f1f2013-03-27 22:26:03 +00005WiringPi2: WiringPi version 2 implements new functions for managing IO expanders.
6
Philip Howard567ee002013-03-27 22:22:00 +00007Prerequisites:
8 You must have python-dev and python-setuptools installed
9 If you manually rebuild the bindings with swig -python wiringpi.i
10 then cat wiringpi_class.py >> wiringpi.py to get the class-based wrapper
11
12Get/setup repo:
Philip Howard0429f1f2013-03-27 22:26:03 +000013 git clone https://github.com/Gadgetoid/WiringPi2-Python.git
Philip Howard567ee002013-03-27 22:22:00 +000014 cd WiringPi-Python
15 git submodule update --init
16
17Build & install with:
18 sudo python setup.py install
19
20Class-based Usage:
Philip Howard0429f1f2013-03-27 22:26:03 +000021 No classes have been created for this version yet.
Philip Howard567ee002013-03-27 22:22:00 +000022
23Usage:
24 import wiringpi
25 wiringpi.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
26 OR
27 wiringpi.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
28 OR
29 wiringpi.wiringPiSetupGpio // For GPIO pin numbering
30
Philip Howard0429f1f2013-03-27 22:26:03 +000031 Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
32 wiringpi.mcp23017Setup(65,0x20)
33 wiringpi.pinMode(65,1)
34 wiringpi.digitalWrite(65,1)
35
Philip Howard567ee002013-03-27 22:22:00 +000036 General IO:
37 wiringpi.pinMode(1,1) // Set pin 1 to output
38 wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1
39 wiringpi.digitalRead(1) // Read pin 1
40
41 Bit shifting:
42 wiringpi.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
43
44 Serial:
45 serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
46 wiringpi.serialPuts(serial,"hello")
47 wiringpi.serialClose(serial) // Pass in ID
48
49Full details at:
Philip Howard0429f1f2013-03-27 22:26:03 +000050 http://www.wiringpi.com