Posted on

Halloween Monster Box

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 –

Distance Sensor –

6 AA Battery Pack –

Mini 9g Servo – like these but there are loads on ebay. None that I can recommend having never used them

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.

The servo itself is stuck on to the side of the box with, surprise surprise, more sticky tape.

I have run out of switches so I soldered up a bit of protoboard with a couple of header pins and used a couple of jumpers as the switch.

The code is pretty simple and I am sure I will be told, at length, the number of ways that it could be done better!


int sensorPin = A0;
int distance = 0;
int servopin = 9;
int time = 0;
#include <Servo.h> 
Servo myservo;
void setup() 
void loop(){
distance = 12343.85 * pow(analogRead(sensorPin),-1.15);
if (distance<75){
time = random(1000, 5000);


Pre decoration the box runs like this

Finally finished – not perfect by a long shot but it should entertain a group of 2-4 year olds for 10 minutes!

I apologise for the video – it wouldn’t focus on the black when it was closed! (this is the best of the bunch though!)