The basic idea:
A pair of glowing bloodshot eyes that would peek at you out of a box when you got close. To make it a little more realistic there is some minor movement of the eyes balls, will look left right, up and down depending on the distance to the ultrasonic sensors.
1 Maple microcontroller board (Should also work with Arduino Mega)
1 hinged box
2 white ping pong balls
2 RGB LED
1 sheet of .6mm aluminium
3 small (or micro) servos
1 standard servo
2 ultrasonic distance sensor (Maxbotix LV-MaxSonar-EZ1)
2 paper clips
2 15 ohm resistors
4 10 ohm resistors
wall plug 5v 1000mA
Misc 3mm screws and nuts
Misc jumper leads
Misc tiny screws
Optional materials (I used them, but not really required if you don't want them)
2 Ultra violate LED
1 thermistor 10K ohm
1 light dependant resister
2 10K ohm resistors
2 100 ohm resistors
Step 1: Make the Eye Balls
Take 2 white ping pong balls. I actually had a lot of trouble finding white ones, most places only had orange ones, I finally found them at Rebal sports.
Using paint for model making paint on a pupil and some red blood shot veins. I choose blue eyes, but colour is up to you.
Using a hot glue gun attach a short 3mm screw at the bottom and top of each eye ball. You want the pupil to be as close as you can to the middle, I suggest you mark the top and bottom with pencil first as it makes it a lot easier to know where to put the glue. Take your time and get the position perfect.
Using a Dremil make a whole at the back of the pin pong ball that will fit a 5mm RGB LED snuggly. Use the hot glue gun to secure the LED in place.
Bend the tails of the LEDs so they don't take up so much space. Now is a good time to connect the LED to ensure it is all working.
Repeat for the second ping pong ball / eye.
Step 2: Create a Inner Frame for the Eyes
Out of paper create a template for your eyes. The eyes will need to be as close to the front as possible, there will need to be enough room behind the eyes to mount your small servos and enough room between the servos and the eye balls for the LED connectors to move around. You only need the depth to hold the servos at the botom, make the top only big enough to hold the eye balls, this will make it a bit lighter and will give the tilt mechanism more room to move. The actual design you end up with will depend on the size of the servos you use.
After you made something that works with paper, transfer your design to .6mm aluminium sheet. Originally the thought of this scarred me as I had never worked with aluminium sheet before. I very quickly discovered it is almost as easy as working with paper. First you get yourself some aviation tin snips, watch it they come in 3 types, one for cutting straight, another for cutting left bends and a third to cut right bends, you need the straight cut tin snips which will be yellow. For bending the aluminium sheet the easiest way for me was to clamp the sheet between two pieces of word, then using a third piece fold over the edge, give it a go, it is really simple.
To join the aluminium I used 3mm screws and nuts, I could have used pop rivits, but at the time I did not have the equipment and I thought it was too difficult, since then I have also found out that using pop rivits is also really easy.
Drill holes for the screws that are attached to the eye balls, I found the Dremil good for this.
Cut square holes for the servos, once again the Dremil was great for that. Then drill holes for the servos mounting screws.
Drill a hole in one side, exactly in line with the middle of the eye ball. Later this will be used to attach this inner frame to an outer frame to allow the eye balls to tilt up and down, if it is off center they eyes will move up and down instead of just looking up and down.
Attach the eye balls and the 2 servos.
Using hot glue, attach a left over server attachements to the screw that sticks out of the frame from each of the eye balls.
Using a paper clip connect the servos to the eye balls. (easiest to see the last picture below).
Attach a longer screw (at least 15 to 25mm) to the hole you drilled in the side of the frame.
Step 3: Create the Outer Frame
Using .6mm aluminium create an outer frame for the tilt mechanism. Later this will attach inside the lid of the wooden box, and will hold the inner frame and eyes and will allow them to tilt up and down.
Design is very simple, see the attached picture. On one side is whole for the last small servo to be mounted, on the other side is a hole that will be used later for the screw from the inner frame. Again take your time here and make sure you get the alignment of the servo and screw hole just perfect, line it up with the inner frame making sure there is enough room for the inner frame to move, but not too much room.
Mount the servo, you can screw the servo in now, but do not screw the attachment to.
Step 4: Prepare the Box
The hardest part of this project was to find a suitable box. In the end I had to settle for this box, I found it at Bunnings in the craft section. I needed a hinged box that was big enough to hold the rig for the eye balls and to hold the electronics. It had a latch at the so I had to remove that, unfortunately if you look closely you can see the screw holes. I also wanted a small lip on the lid to hide the tilting a rig a little. But this is the box I got so I had to live with it.
in the front of the box near the bottom use a Dremil to cut out holes that will snuggly fit the proximity sensors.
I wanted to change the colour of the eyes depending on the the ambient light and temperature, its up to you, but if not skip this bit. On one side near the bottom towards the front drill the 4 smallest holes you can with a Dremil. These are to put in the tails of the thermistor and the Light Dependant Resistor (LDR). Again using the Dremil carve out a couple of small notches for the to hide these sensors. (I didn't get a photo of this before painting, but you can see it in the picture below after painting.)
Mount the outer frame of the tilt mechanism (that was made during the previous step) on the inside of the top lid. The hard part here is finding some screws that were small enough not to poke out the top of the box. I could not find any in the screw section at Bunnings, what I did was look at the hinges, there was small decorative brass hinges which came with tiny screws, they were cheep enough I was happy to throw out the hinges and keep the screws.
For the last time using the Dremil, make a hole at the back corner of the box that will fit the power connect through.
Now undercoat and paint matt black. I used spray paint and was quite happy to get some on the aluminium as it blended in quite well in the finished job.
Step 5: Put the Bits Together
Put the ultrasonic sensors in the front, hold them in with a little hot glue.
Out the thermistor and LDR sensor in, hold them in with a little hot glue.
We now need to mount the final servo that will be used to open the box, measure out how deep the box is and how wide the servo is and cut of a bit of wood to fit inside the box so the servo can push against. Using some of the spare aluminium to wrap around the servo to hold it to the lid. Now with a bit of trial and error, find the spot where the servo and wood block go. Screw the servo to the lid and stick the wooden block with hot glue. I was worried the servo would wear out the wooden block in time so I stuck some left over aluminium to the block, also with hot glue.
Step 6: Add the Electronics
Throw in the bread board and the micro controller into the box.
The circuitry is very simple, on the left hand side the power strip is 5 volts taken from the VIN pin. On the Right hand side is 3.3 volts from the VCC pin.
Note that I had a 5 volt power supply to connect to, if you have something higher you will need to put a voltage regulator on it. Also note you cannon power this via a USB port as it will draw more than the 500mA.
The left hand 5 volt powers the servos, the right hand 3.3 volt powers the sensors.
The distance sensors have an analoge out so you can connect direct to your analog pins.
The servos can connect direct to PWM pins.
The LEDs need a resistor between each positive terminal and a PWM pin. The red uses 15 ohm and the blue and green use 10 ohm, you will need to adjust these if you use a 5 volt board.
The LDR and the thermistor each use a basic voltage divider circuit, there are plenty of examples floating around the net but it goes like this:
3.3v (vcc) to sensor in, sensor out to analog in pin and also to 10k ohm resistor, 10k ohm resistor to ground.
I thought it might be good to have an ultraviolet back light so I connected 2 UV LEDs, one on each side of the bread board. This is optional and the benefits are questionable. They will need a 100 ohm resistor each.
The pins I used are:
1 - red left
2 - green left
3 - blue left
5 - red right
6 - green right
7 - blue right
8 - right servo
9 - left servo
11 - tilt servo
12 - lid open/close servo
15 - distance sensor left
16 - distance sensor right
17 - thermistor
18 - LDR32 - UV left
34 - UV right
Of course if you use a different board (ie Arduino mega) you will have different pin outs and will need to adjust accordingly. I only use the maple because that is the board I had available that had enough PWM pin outs.
Step 7: The Code
The code is attached, if you just you want to throw it on the board go for it, however here I will also try to explain what the code is doing.
It is a basic state machine with 3 states, OPEN, PEEK, CLOSED. OPEN and CLOSED can change to PEEK. PEEK can change to OPEN or CLOSE. You cannot go direct from OPEN to CLOSE.
CLOSE will turn lights off and set the tilt servo to close the lid.
PEEK will turn the lights to blue/purple colour, set the servos for the eyes to about the center, sets the servo for the lid to half open.
OPEN will set the lights on (depending on the thermistor and the LDR), set the servo for the lid to full open. While open there is a random number that will, if the correct number, move the eyes up, down, left, right. If the distance is closer the eyes will look up, and move slightly in (to simulate focus). If one distance sensor is closer than the other, then the eyes will look to that side.
That is about as simple as it is.