Hardware Reference
In-Depth Information
Programming the Door Control Block
With the door lock connected to the interface, it is time to write the software. he function
of the door controller is to send a short signal to unlock the door. You will edit the
TestDoorController class.
Open the ile door_controller.py and edit the code to add the following lines.
Add these statements to the beginning of the program:
import piface.pfio as piface
from time import sleep
Add this before the main function:
class DoorControllerPiFace:
def send_open_pulse(self):
piface.digital_write(0,1)
sleep(5)
piface.digital_write(0,0)
Update the main function to make use of this class. Change
doorController = TestDoorController()
to
doorController = DoorControllerPiFace()
Run the entire program, and check that instead of printing unlock the door , the door
lock is released for ive seconds and then locks again.
Now that you've successfully built and tested the output stage, it's time to get the input from
the user when he or she wants to open the door.
The Input Block
Continuing with the theme of keeping things simple at irst, you will start with the input
block asking the user to type a password on a standard USB keyboard.
Search WWH ::




Custom Search