A program to flash an LED must repeatedly turn an output on, wait for a period and then turn it off again. It is shown below:
+
+
<syntaxhighlight lang="python">
+
from time import sleep
+
import piface.pfio as pfio
+
pfio.init()
+
while(True):
+
pfio.digital_write(0,1) #turn on
+
sleep(1)
+
pfio.digital_write(0,0) #turn off
+
sleep(1)
+
</syntaxhighlight>
+
+
=== Lire une entrée ===
+
To read the state of an input use the {{fname|pfio.digital_read(pin)}} function. If a button is pressed the function returns a ''1'', otherwise it returns a ''0''.
+
+
Start a new Python interpreter and type the following:
+
+
<syntaxhighlight lang="python">
+
import piface.pfio as pfio
+
pfio.init()
+
pfio.digital_read(0)
+
</syntaxhighlight>
+
+
Python prints ''0''.
+
+
Hold down the first switch, labelled ''S0'', and type {{fname|pfio.digital_read(0)}} again.