Farnell PiFace Control & Display Raspberry Pi Add-on Board

1

The PiFace Control and Display (PiFace CAD) addon for the Raspberry Pi is a great way of adding a screen and buttons to your Pi. Once you’ve installed the Python libraries it is easy to get your code to interact with the screen while receiving input from the five buttons and rocker switch.

This allows you to control your creation with menu based commands. It’s even got an Infra-red receiver so you can use a remote control. By making the hardware easy and providing a Python library you can spend more time on your functionality rather than worrying about wiring up your own switches.

PiFace Control & Display

The PiFace has a community page on Element14 which includes links to the user manual and other resources. It is available for £25 from Farnell or CPC.

Specifications

  • 16 character by 2 line alphanumeric display
  • LED display backlight
  • User definable custom characters
  • 3-position navigation switch
  • 5 tactile switches
  • IR receiver for infrared remote control
  • Quick and easy menu building Python libraries provided

Installation

Make sure you are using the lastest version of Raspbian:

sudo apt-get update
sudo apt-get upgrade

This may take 5-10 minutes but keeping your system up to date with the latest packages and drivers saves lots of time later if things don’t work as expected.

Activate SPI Interface

The PiFace board uses the SPI interface on the GPIO header but this usually needs to be enabled if you haven’t done so previously. Please follow my Enabling the SPI Interface on the Pi Tutorial.

Install piFaceCAD

The piFace CAD package gives you the libraries required to control the device in your own Python scripts. You can install pifacecad (for Python 3 and 2) with the following command:

sudo apt-get install python{,3}-pifacecad

The installation may take 5-10 minutes and you should reboot when it has finished :

sudo reboot

Now you can test the installation by running the sysinfo.py program:

python3 /usr/share/doc/python3-pifacecad/examples/sysinfo.py

This should display your IP address, temperature and CPU load.

PiFace Control & Display

Example Python Script

Here is another simple script to test the five switches :

#!/usr/bin/python
#--------------------------------------
#
#            Raspberry Pi
#     PiFace Control & Display
#
# Test the PiFace Control & Display
# switches (S1-S5)
#
# Author : Matt Hawkins
# Date   : 25/08/2014
#
# http://www.raspberrypi-spy.co.uk/
#
#--------------------------------------

# Import PiFace library
import pifacecad as pf

cad = pf.PiFaceCAD()
cad.lcd.backlight_on()

cad.lcd.clear()

cad.lcd.write("Press a switch")

while True:

  for x in range(5):
    if cad.switches[x].value==1:
      cad.lcd.clear()
      cad.lcd.write("Switch " + str(x+1))

You download this script directly to your Pi using :

wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/pifacecad_test.py

It can be run using :

python pifacecad_test.py

There are more examples on the PiFace CAD Documentation Page.

Model B+

The PiFace Control & Display fits all Pi models but due to the position of the GPIO header it sits at a slight angle on the B+. One corner of the PCB makes contact with the metal USB socket so a small piece of tape is a good idea to ensure solder joints don’t touch it.

PiFace CAD on Model B+

PiFace CAD on Model B+

Endless Applications

What you use your PiFace CAD for is down to your imagination. The first project I used it in was a display for a Minecraft game written in Python.

Operation Counterstrike PiFace

 

Share.

1 Comment

Leave A Reply