Installing software under Linux
This guide assumes you are installing on Raspbian on a Raspberry Pi connected to the Internet
to allow you to download packages with apt-get.
Make sure you are using the lastest version of Raspbian by opening a terminal and typing:
sudo apt-get update && sudo apt-get upgrade
To install the PiFace Relay+ libraries for Python 2 and 3, in a terminal, type the following
command:
sudo apt-get install python3-pifacerelayplus
Testing
You can test the PiFace Relay+ software by running one of the example programs in the
examples directory:
python3 /usr/share/doc/python3-pifacerelayplus/examples/blink.py
This test will toggle one of the relays on and off (you should hear it click and see the
corresponding LED flash).
Writing an example Python program
This example will walk you through how to write a Python program for PiFace™ Relay+ to turn a
relay on and off. To write your program, open a Terminal window on your Raspberry Pi® and
type
nano relayonof f.py
to create the program file.
Import the Relay+ module and the time module (which you will use for delays) with the following
lines:
import pifacerelayplus
import time
Now initialise your Relay+.
pfr = pifacerelayplus.PiFaceRelayPlus(pifacerelayplus.RELAY)
In this line the
pifacerelayplus.RELAY
refers to any PiFace™ EXTRA board you have
attached. Refer to that EXTRA board’s documentation for what you should put here.
Summary of Contents for Relay+
Page 3: ...Tour of hardware ...