I'm using an RPi 2 with a PiFace Digital 2 interface and a PIR attached.
Code: Select all
# Alarm program by Francesco Balsamo # # Using a PIR sensor with inverted logic # from time import sleep import pifacedigitalio as pfio # import piface.pfio as pfio pfio.init() while(True): for pin_number in range(1,3): if pfio.digital_read(pin_number) == 0: pfio.digital_write(pin_number,1) # Using only the leds else: pfio.digital_write(pin_number,0) # Disabling only the leds
http://www.piface.org.uk/static/img/pif ... iagram.png
(not sure how to insert diagrams)....
When I run this program the LED in position 1 comes on. When any movement is detected LED 2 comes on for a second or so.
I'm very pleased with this magic which took me ages to come across, but I would like to change it so that only LED 0 is used, ie, it's normally off but comes on when there is movement. If anyone could amend the above code, I would be very grateful.