blob: 790e468c647b0b5ccb5dbbfc86c58e47c2d6bb24 [file] [log] [blame]
Philip Howardfa09d182013-04-01 21:11:00 +00001======
2WiringPi 2 for Python
3======
4
Philip Howardfa09d182013-04-01 21:11:00 +00005WiringPi: An implementation of most of the Arduino Wiring
6 functions for the Raspberry Pi
7
8WiringPi2: WiringPi version 2 implements new functions for managing IO expanders.
9
10Testing:
11========
12Build with gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
13Built against Python 2.7.2, Python 3.2.3
14
15Prerequisites:
16==============
17You must have python-dev and python-setuptools installed
18If you manually rebuild the bindings with swig -python wiringpi.i
19
20Get/setup repo:
21===============
22git clone https://github.com/Gadgetoid/WiringPi2-Python.git
23cd WiringPi2-Python
24
25Build & install with:
26=====================
27sudo python setup.py install
28
29Or Python 3
30sudo python3 setup.py install
31
32Class-based Usage:
33==================
34Description incoming!
35
36Usage:
37======
38import wiringpi2
39wiringpi2.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
40OR
41wiringpi2.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
42OR
43wiringpi2.wiringPiSetupGpio // For GPIO pin numbering
44
45Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
46wiringpi2.mcp23017Setup(65,0x20)
47wiringpi2.pinMode(65,1)
48wiringpi2.digitalWrite(65,1)
49
50General IO:
51-----------
52wiringpi2.pinMode(1,1) // Set pin 1 to output
53wiringpi2.digitalWrite(1,1) // Write 1 HIGH to pin 1
54wiringpi2.digitalRead(1) // Read pin 1
55
56Bit shifting:
57-------------
58wiringpi2.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
59
60Serial:
61-------
62serial = wiringpi2.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
63wiringpi2.serialPuts(serial,"hello")
64wiringpi2.serialClose(serial) // Pass in ID
65
66Full details at:
67----------------
68http://www.wiringpi.com