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