Introduction: Setting Up a PiFace With Your Raspberry Pi

This is a basic guide aimed at beginners who have just received a Raspberry Pi / Pi-face and want to know how to set it up, I felt the need to write this up after receiving a PiFace and not be able to find any decent documentation on how to set it up. I hope this helps and let me know if you have any comments. You should be able to have the PiFace setup and working within an hour.

If you looking for a place to buy the PiFace internationally go here - Buy PiFace Worldwide

Step 1: Preparing the SD Card

Download the 'Wheezy Raspian' image file from the Raspberry Pi's website download page you will also need to download the Win32DiskImager, also on the download page (assuming you are using windows). Connect your SD card to your PC, open up Win32DiskImager and browse for the image file you just downloaded (you will need to unzip it first), select your SD card drive letter from the device drop down list and then press write to write the image to your disk.

Step 2: Connecting the Pi/Piface

Your PiFace has a 26 port connector on the bottom that connects to the 26 pin GPIO connector on your Raspberry Pi, connect these together, pop the SD card in the SD Card Slot on the Pi, and plug in your network cable, monitor, keyboard and mouse.

Power on the Pi.

Step 3: Setting Up Your Pi

On the initial setup screen you will most likely want to select the Expand File System option using the arrow keys to move and enter to select, when the pi comes back to this screen you will want to select option 3 to enable boot to desktop, on the next screen select 'Desktop log in as user 'pi' at the graphical desktop' as this will set your raspberry pi to auto login to the desktop as the user 'pi'.

Step 4: Configuring the Pi for PiFace

The first thing we need to do is enable the SPI driver, so open a LX Terminal and type in
sudo nano /etc/modprobe.d/raspi-blacklist.conf
This should open the file in the command line, using the arrows scroll down to the line that says
blacklist spi-bcm2708
and insert a # in front of it (this comments out the line stopping the SPI driver being disabled on boot up), press
CTRL + O and then Enter
to write out (save the file) followed by
CTRL + X
to exit nano. Reboot your Pi. Tthe PiFace libraries are now installed in the raspbian image by default however we still need to install the emulator which is handy for testing (this is not required to make the PiFace run). To install the emulator use the following command in your terminal window, this will take a few minutes
sudo apt-get install python3-pifacedigital-emulator
Once installed you should have a desktop icon for the emulator.


Step 5: Testing the PiFace (Emulator)

(This assumes you have installed the Emulator from the Previous Step)

Open up the PiFace Digital Emulator, from the 'Enable' menu select 'Output Control'.
Pressing buttons 0 - 7 in the output control box should light up all the LEDs on your PiFace Board, assuming your board lights up your PiFace is now fully configured and working.

Step 6: Testing the PiFace With Python

We will be using python in a quick demo to show how to turn one of the outputs on and off, the LED on the board for the corresponding output will also light up. You do not need to have any extra components attached to the PiFace to do this test. Open IDLE3 from the desktop. During this step all code you have to enter will be indented into the page to make it easier to identify.

Import the PiFace Python Libraries:
import pifacedigitalio

Create a new PiFace Digital Object, call it pfd. Note: In Python the case of the code is important, make sure you copy this letter for letter.
pfd = pifacedigitalio.PiFaceDigital()

The output pins are numbered 0 - 7 (from right to left) the very first pin is not number as this is the pin that provides voltage, you do not control this one. We will be playing with pin 7.

Turn Pin 7 on
pfd.output_pins[7].value = 1

Turn Pin 7 off
pfd.output_pins[7].turn_off()

You should have just seen the LED at output pin 7 turn on and off and that's it for this instructable, look out for my next one where I will be showing you how you can use the above code and a tiny bit more to make multiple LEDs flash in a chasing pattern.
Raspberry Pi Contest

Participated in the
Raspberry Pi Contest