A cheap spider decoration, hollowed out and enhanced with an A+ and a motion sensor that activated evil red eyes.
The skinny power bank powered the Pi happily for over 4 hours.
The styrofoam body of the spider made it easy to hollow out a cavity for the A+
import RPi.GPIO as GPIOimport timeGPIO.setmode(GPIO.BOARD)# Setup the pins we'll useGPIO_PIR = 26GPIO.setup(13,GPIO.OUT)GPIO.setup(GPIO_PIR,GPIO.IN)GPIO.setup(15,GPIO.OUT)print "PIR Alarm active (CTRL-C to exit)"Current_State = 0Previous_State = 0try:print "Waiting for PIR to settle ..."# Loop until PIR output is 0while GPIO.input(GPIO_PIR)==1:Current_State = 0print " Ready"# Loop until users quits with CTRL-Cwhile True :# Read PIR stateCurrent_State = GPIO.input(GPIO_PIR)if Current_State==1 and Previous_State==0:# PIR is triggeredprint " ALARM!"GPIO.output(13,1)GPIO.output(15,1)time.sleep(5)GPIO.output(13,0)GPIO.output(15,0)# Record previous statePrevious_State=1elif Current_State==0 and Previous_State==1:# PIR has returned to ready stateprint " Ready"Previous_State=0# Wait for 10 millisecondstime.sleep(0.01)except KeyboardInterrupt:print " Quit"# Reset GPIO settingsGPIO.cleanup()
A (cute rather than scary) bat that descended from the porch, also activated by a Pi with a motion sensor and lowered by a stepper motor.
The Pimoroni BlackHAT Hackr and the Pi touch display made is really easy to set everything up on the windowseal so that just the wires from the picoborg board could be passed out through the window to the motor. A shaft adapter and some Lego made a nice winding mechanism.
A sinister Lego skull with Pi-controlled blinking eyes.
Why bother building some supports for the breadboards when you can just wedge the LEDs through the eye sockets. I don't know, kids today, eh?
Ozzy wrote the code for this and I thought the use of a simple random function to control the frequency of blinking was particularly effective and gave the impression of a lurking creature rather than just a thing with regular flashing eyes.
import RPi.GPIO as GPIOimport timeimport randomGPIO.setmode(GPIO.BOARD)GPIO.setup(13,GPIO.OUT)GPIO.setup(15,GPIO.OUT)def eyes_blinking(pin1,pin2):GPIO.output(pin1, GPIO.HIGH)GPIO.output(pin2, GPIO.HIGH)time.sleep(random.randint(1,3))GPIO.output(pin1, GPIO.LOW)GPIO.output(pin2, GPIO.LOW)time.sleep(0.2)counter = 0while True:eyes_blinking(13,15)counter+=1print ('boo ' + str(counter))