Firstly, the word “primitive” in the title describes my code and not this program’s ability to differentiate between primitive or advanced intruders.
The project uses the Explorer Pro HAT, three male to female jumper leads (one to 5v0, one to ground and one to input one), they, in turn, are connected to a £2 PIR sensor.
I have based my little project on a post by Gisky (so many thanks to him for the inspiration):-
I must admit the code is a total cut ‘n’ shut job and is cobbled together from the Explorer Pro’s test and welcome files and the post from Gisky.
If anyone has the time to clean it up, I’d be interested in seeing their results.
Nevertheless, it works on my B+ running Raspbian, so here it is. I hope you enjoy. The code will evolve over time, adding more features. The newer versions will be at the bottom of this page:-
import explorerhat import time explorerhat.light.off() def alert(pin): print "*** WARNING!!! INTRUDER ALERT!!! ***" explorerhat.light.red.pulse() explorerhat.light.green.off() return explorerhat.input.one.pressed(alert) def zeroalert(pin): print "*** SYSTEM NORMAL ***" explorerhat.light.red.off() explorerhat.light.green.on() explorerhat.input.one.released(zeroalert) explorerhat.pause()