blob: 2889e216abfbfb7e752d796da673f269cf150675 [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 Howardb1169c82013-03-27 23:08:14 +00007Testing:
8 Build with gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
9 Built against Python 2.7.2, Python 3.2.3
10
Philip Howard567ee002013-03-27 22:22:00 +000011Prerequisites:
12 You must have python-dev and python-setuptools installed
13 If you manually rebuild the bindings with swig -python wiringpi.i
Philip Howard567ee002013-03-27 22:22:00 +000014
15Get/setup repo:
Philip Howard0429f1f2013-03-27 22:26:03 +000016 git clone https://github.com/Gadgetoid/WiringPi2-Python.git
Philip Howardfb7c8912013-03-27 22:48:19 +000017 cd WiringPi2-Python
Philip Howard567ee002013-03-27 22:22:00 +000018
19Build & install with:
20 sudo python setup.py install
21
Philip Howardfb7c8912013-03-27 22:48:19 +000022Or Python 3
23 sudo python3 setup.py install
24
Philip Howard567ee002013-03-27 22:22:00 +000025Class-based Usage:
Philip Howard0429f1f2013-03-27 22:26:03 +000026 No classes have been created for this version yet.
Philip Howard567ee002013-03-27 22:22:00 +000027
28Usage:
Philip Howardb1169c82013-03-27 23:08:14 +000029 import wiringpi2
30 wiringpi2.wiringPiSetup // For sequential pin numbering, one of these MUST be called before using IO functions
Philip Howard567ee002013-03-27 22:22:00 +000031 OR
Philip Howardb1169c82013-03-27 23:08:14 +000032 wiringpi2.wiringPiSetupSys // For /sys/class/gpio with GPIO pin numbering
Philip Howard567ee002013-03-27 22:22:00 +000033 OR
Philip Howardb1169c82013-03-27 23:08:14 +000034 wiringpi2.wiringPiSetupGpio // For GPIO pin numbering
Philip Howard567ee002013-03-27 22:22:00 +000035
Philip Howard0429f1f2013-03-27 22:26:03 +000036 Setting up IO expanders (This example was tested on a quick2wire board with one digital IO expansion board connected via I2C):
Philip Howardb1169c82013-03-27 23:08:14 +000037 wiringpi2.mcp23017Setup(65,0x20)
38 wiringpi2.pinMode(65,1)
39 wiringpi2.digitalWrite(65,1)
Philip Howard0429f1f2013-03-27 22:26:03 +000040
Philip Howard567ee002013-03-27 22:22:00 +000041 General IO:
Philip Howardb1169c82013-03-27 23:08:14 +000042 wiringpi2.pinMode(1,1) // Set pin 1 to output
43 wiringpi2.digitalWrite(1,1) // Write 1 HIGH to pin 1
44 wiringpi2.digitalRead(1) // Read pin 1
Philip Howard567ee002013-03-27 22:22:00 +000045
46 Bit shifting:
Philip Howardb1169c82013-03-27 23:08:14 +000047 wiringpi2.shiftOut(1,2,0,123) // Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2
Philip Howard567ee002013-03-27 22:22:00 +000048
49 Serial:
Philip Howardb1169c82013-03-27 23:08:14 +000050 serial = wiringpi2.serialOpen('/dev/ttyAMA0',9600) // Requires device/baud and returns an ID
51 wiringpi2.serialPuts(serial,"hello")
52 wiringpi2.serialClose(serial) // Pass in ID
Philip Howard567ee002013-03-27 22:22:00 +000053
54Full details at:
Philip Howard0429f1f2013-03-27 22:26:03 +000055 http://www.wiringpi.com