blob: 61f23db7b1950244b7db8f85b9f32fab7b58af31 [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 Howardfb7c8912013-03-27 22:48:19 +000014 cd WiringPi2-Python
Philip Howard567ee002013-03-27 22:22:00 +000015
16Build & install with:
17 sudo python setup.py install
18
Philip Howardfb7c8912013-03-27 22:48:19 +000019Or Python 3
20 sudo python3 setup.py install
21
Philip Howard567ee002013-03-27 22:22:00 +000022Class-based Usage:
Philip Howard0429f1f2013-03-27 22:26:03 +000023 No classes have been created for this version yet.
Philip Howard567ee002013-03-27 22:22:00 +000024
25Usage:
26 import wiringpi
27 wiringpi.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
28 OR
29 wiringpi.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
30 OR
31 wiringpi.wiringPiSetupGpio // For GPIO pin numbering
32
Philip Howard0429f1f2013-03-27 22:26:03 +000033 Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
34 wiringpi.mcp23017Setup(65,0x20)
35 wiringpi.pinMode(65,1)
36 wiringpi.digitalWrite(65,1)
37
Philip Howard567ee002013-03-27 22:22:00 +000038 General IO:
39 wiringpi.pinMode(1,1) // Set pin 1 to output
40 wiringpi.digitalWrite(1,1) // Write 1 HIGH to pin 1
41 wiringpi.digitalRead(1) // Read pin 1
42
43 Bit shifting:
44 wiringpi.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
45
46 Serial:
47 serial = wiringpi.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
48 wiringpi.serialPuts(serial,"hello")
49 wiringpi.serialClose(serial) // Pass in ID
50
51Full details at:
Philip Howard0429f1f2013-03-27 22:26:03 +000052 http://www.wiringpi.com