With the introduction of wiringPi version 2, there is now a new website dedicated to all things wiringPi including the new PiFace interface code. This page will remain for historical purposes, but please click here to take you to the current PiFace page on the wiringPi Site.
The PiFace board
Symbolic view from above with the composite video connector at the top, and the HDMI connector at the bottom.
- sw0 through sw3 are connected to inputs 0 through 3 respectively.
- Relay 2 + LED 2 is connected to output 0
- Relay 1 + LED 1 is connected to output 1
- LED 3 is connected to output 2
- LED 4 is connected to output 3
The standard wiringPi functions work with the PiFace with a few notable exceptions and differences:
- Because we can’t control the direction of the pins – it’s fixed in hardware, there are no pin direction functions.
- Numbering starts at zero and carries on through 7 for both inputs and outputs. (so you can digitalWrite (0,1), but digitalRead (0) returns the value on the input pin, not the output pin)
- The PiFace only has internal pull-up resistors and these are not enabled by default. You should enable them if reading the switches on the PiFace.
To use the PiFace, you must call the PiFace initialisation routine in your program where you would normally call one of the other wiringPi setup functions:
After this, you can then call the usual digitalWrite(), digitalRead() and pullUpDnControl() functions, as required.
Download and Install
See the wiringPi download and install pages for more details. There is working example called piface.c in the examples directory. You do need to be root to run the program (for now), so after typing make, then type sudo ./piface then you can push the buttons and make the LEDs/Relays turn on and off.