We normally throw a Halloween party in our house but this year we have managed to dodge the bullet friends of ours have volunteered to have a house full of over sugared children.
I couldn’t leave it at that however so I have created a Monster Box for my sons to take with them and scare the other guests.
The parts list is pretty basic:
Arduino Uno – http://www.hobbytronics.co.uk/arduino/arduino-uno-r3
Distance Sensor – http://www.hobbytronics.co.uk/GP2Y0A21-distance-sensor?keyword=distance
6 AA Battery Pack – http://www.maplin.co.uk/aa-size-battery-holders-31427
Mini 9g Servo – like these but there are loads on ebay. None that I can recommend having never used them http://www.ebay.co.uk/itm/5x-Tower-Pro-Micro-RC-SG90-9G-Servo-for-Car-Plane-Boat-Helicopter-Hobby-UK-/290787324013?pt=UK_ToysGames_RadioControlled_JN&hash=item43b446706d
Bits of wire, string, sticky tape, sticks, paint, glue etc.
The principle is pretty simple:
Distance sensor feeds back distance to Arduino
Arduino triggers servo when distance is less than n cm
Box stays shut for x time then opens again (as long as distance n is great enough)
Servo signal wire is connected to pin 9, Distance sensor on pin A0, ground to ground, +ve to arduino 5v. Battery pack is to the arduino gnd and Vin rather than the barrel jack.
The sensor has a slot cut in the front of the box and is taped in place (Bottom of the Picture).
The servo has a stick (part of a very broken RC helicopter frame in this case) wired to the end of the arm, the stick is then stuck to the lid of the box.