Installing:

 

I did a variation on the instructions to get the board working. I had to write a older version of the Operating system from 2016 to a SD card.  Using the current image , I could not find the PIFace  software to install from the current repository, You can download older versions from this link.

 

1. Enable SPI with the configuration tool.

 

2. Install PiFace Digital Software

 

sudo apt-get install python3-pifacedigital-emulator

sudo reboot

 

3. Make sure the power is off before connecting the board to the Raspberry Pi.

 

Testing:

 

1. Blinky Test

 

python3 /usr/share/doc/python3-pifacedigitalio/examples/blink.py

 

Use Ctrl + C  to stop it

 

2. Emulator Test

 

Type in the terminal: pifacedigital-emulator or click on the desktop icon. The emulator should open and allows manual control of Outputs and Inputs. Select by clicking on Enable option.

In this example I have selected 3 and 5. The LED lights have turned on in the Emulator and the PiFace

 

 

 

The PiFace example directory can be found at:

 

cd /usr/share/doc/python3-pifacedigitalio/examples

 

Flashing a LED example

from time import sleep
import pifacedigitalio as p
pinit()
while(True):
      p.digital_write(0,1) #turn on      sleep(1)
      p.digital_write(0,0) #turn off
      sleep(1)

 

Pushing a button example

 

To read the state of an input use the p.digital_read(pin) function as shown below. If a button is pressed the function returns a 1, otherwise it returns a 0.

 

import pifacedigitalio as p
p.init()
p.digital_read(1)

 

Python prints 0.

Now hold down switch number 1 (marked S1) and type p.digital_read(1) again.

Python prints 1.