Smiling Santa

by MikeTheMaker in Circuits > Sensors

1356 Views, 3 Favorites, 0 Comments

Smiling Santa

NXP3590 project photo.jpg
This interactive display responds to a person's smile.  A camera searches for faces then detects smiles and takes a photo.  In this mode, an LED on the camera's "searching base" goes dark.  Interface circuitry (mbed LPC 1768) links the camera with the smiling Santa face. If you want to smile at Santa in person, we will be at the Maker Faire in San Mateo during May of 2011.

NXP3590 Block Diag.jpg
This is the setup--a camera detects a smile then a microcontroller operates two servo motors and LED's for a defined time period.  That's it.

Schematic

NXP3590 schematic.jpg
Voltage across a resistor/photocell pair changes when the amount of light striking the photocell changes. This voltage is provided to the LPC 1768 (microcontroller--you could use an Arduino, it would just mean using different pins and different software code) as an analog input. Outputs from the LPC 1768 turn on the LED eyes and activate two servomotors.  The servomotors are connected by fishing line to the ends of the flexible rubber mouth.

Software

Analog voltage input (the camera has detected a smile) is received on pin 20.  Pin 26 (Santa's eyes and LED1 on the processor module) is activated for two seconds upon detection of a smile.  Pins 21 and 22 are used to control the servomotors that create the smile/non-smile face.  It is easy in software to adjust the position (smile and non-smile) of each side of the smiling "lip" as well as the duration of the smile.

#include "mbed.h"
#include "Servo.h"

AnalogIn ain(p20);
DigitalOut led(LED1);
DigitalOut relay(p26);
Servo servo1(p21);
Servo servo2(p22);
void SetPosition(int NewPos);
void Enable(int StartPos,int Period);


int main () { servo1.Enable(1500,20000);
    servo2.Enable(1500,20000);
while (1) {
        if(ain < .2) {
        led = 0; relay = 0;
        servo1.SetPosition(1000);//rt smile down
        servo2.SetPosition(1200);//lft smile down
        wait(.5); } else {


        led =1; relay = 1;
        servo1.SetPosition(2000);
        servo2.SetPosition(500);
        wait(2);} }
}



Construction

NXP3590 template.jpg
Let's start the construction by cutting a disc from 1/4 inch thick plywood as shown in the template above.

NXP3590 01.jpg
The disc should look like this.

NXP3590 02.jpg
Using wood screws, attach a 3/4 inch by 3/4 inch by 3 inch back support brace.

NXP3590 03.jpg
Attach a 2 foot long piece of aluminum trim channel (channel is made for 3/4 inch plywood and is available in building supply stores) to the back support brace.

NXP3590 04.jpg
Attach a 6 1/2 inch long by 3/4 inch by 3/4 inch block of wood to the disc adjacent to the slits.

NXP3590 05.jpg
Attach a 3/4 inch by 3/4 inch by 4 inch pice of wood centered on the last piece you installed.

NXP3590 06.jpg
Insert another 3/4 inch by 3/4 inch by 6 1/2 inch piece of wood on the last piece installed.

NXP3590 07.jpg
Using small wire (like magnet wire), connect two of the servo hubs (included with the servomotor) so that the radial distance from the servo shaft to the end of the hub is at least one inch.

NXP3590 08.jpg
Drill a 3/8 inch hole in the disc, between the board assembly and the back support. Wires from the servomotors will go up through this hole then down through the aluminum channel in the back.

NXP3590 09.jpg
Using the tiny screws provided with the servomotor, attach the motor to the wood block assembly.

NXP3590 10.jpg
Attach the second servomotor to the other side of the block assembly.

NXP3590 11.jpg
Drill two 1/4 inch holes (separated by 4 inches) near the front of the disc.  The "eye" wires will pass through these holes.  Attach a 12 inch by 24 inch (1/4 inch thick) piece of acrylic to the lower end of the aluminum channel.

NXP3590 13.jpg
From a string of LED Christmas lights, remove two lights to work as eyes.  I chose blue stars, but globes ar any color of your choice will work.  Solder about 3 feet of #22 wire to the light wires and thread this through the disc.

NXP3590 12.jpg
Cut a 3 7/8 inch long piece of acrylic rod (1 inch diameter--I used the clear handle of an upscale toilet plunger).

NXP3590 14.jpg
Using a screw, attach the rod to the aluminum support channel--11 inches from the top.

NXP3590 15.jpg
Drill a 1/4 inch diameter hole in the top and center (connect the holes) end of the rod away from the aluminum support.

NXP3590 16.jpg
Cut a 6 1/2 inch long piece of "eyeglass strap holder" (or any flexible tubing) and attach the center to the acrylic rod with fishing line.

NXP3590 17.jpg
Using a needle, thread fishing line through the ends fo the tubing and tie the ends of the fishing line to the ends of the servomotor hubs.

NXP3590 18.jpg
Using a breadboard (or your preferred method) wire the LPC 1768 as shown in the schematic drawing.

*I was using a battery supply and oscilloscope to troubleshoot when this photo was taken.

NXP3590 19.jpg
Using another acrylic rod, attach a beard assembly 3 1/2 inches below the mouth rod.

NXP3590 20.jpg
Twist wires from the power supply to the breadboard wires.

NXP3590 21.jpg
Tape the wires with electrical tape so that they don't bump together and short out.

Use a Sony DSC TX1 camera and the Sony Party shot base (and Sony AC adapter) for smile detection.  We need a camera with 1) smile detection, 2) smile detection that will stay on indefinitely, 3) smile detection that is indicated by operation of a light, 4) ac power for the camera so that it won't shut down.

NXP3590 22.jpg
Cut a small square of Velcro and punch a hole in the center.  Attach the adhesive side to the party shot base (hole should allow the white LED to shine through).

NXP3590 23.jpg
Attach a photocell to the other side of the Velcro square.  Stick the two pieces of Velcro together, making sure that the photocell is aligned with the "LED hole."

NXP3590 24.jpg
I inserted small screws into the end of the "smile tube" so that gravity would pull the ends of the smile downward.

NXP3590 25.jpg
When you stand in front of the camera and smile, Santa's eyes will glow and his smile will rise.  Adjust the software (servomotor positions) until you are satisfied with the up and down appearance of the smile.

IMG_5208.jpg
This works--but there is still a problem.  The party base rotates left, right, up, and down.  You can't depend on the base being pointed where you want it to be at any given time.  The base is necessary to keep power on the camera and keep the camera in the smile mode (you have to read the party base instructions and program the camera while on the base to stay on). 

I tried disabling the motors in the base, but the processor knew I had pulled the wires and it put the LED's into a flashing mode. So, I started my quest to defeat the pan/tilt mechanism.

Remove three screws from the bottom of the base.

IMG_5210.jpg
Remove two screws from the "tilt" plate.

IMG_5209.jpg
Pull the party base camera socket away from the tilt mechanism.

IMG_5217.jpg
At this point, if you are smart and take my advice, you will cut, nip and otherwise destroy the top of the party housing to get it away from the camera socket.

For some fool reason--maybe thinking I might restore the device someday--I decided to remove the ribbon cable from the camera socket and pull it through the top of the party housing.  This works fine EXCEPT that the end of the ribbon cable is not really a connector; it's more like a 1/16 inch piece of hard exposed cable.  

IMG_5220.jpg
I had to "force/slide" this cable back under a tiny spring loaded connector.  I really thought I'd bought the farm, but it works.

IMG_5221.jpg
Bolt a piece of U shaped tubing to the camera socket.  Place Velcro on the bottom of the party base.  Cut a 2 1/2 inch diameter hole in a piece of acrylic (slightly larger than the rotating element on the base).  

IMG_5222.jpg
Adhere the base to the acrylic such that the rotating part of the base can rotate freely.  Secure the aluminum channel/camera socket to the acrylic upright.

IMG_5224.jpg
Using a 2 inch by 2 inch block of wood, attach the acrylic upright to a 12 inch square acrylic base.  

santafinal.jpg
Almost done.  Line the camera lens up pretty much in the center of Santa's face. Plug the Sony AC power supply into the party base.  Attach the Velcro photocell to the Velcro on the party base.  Attach the camera to the camera socket.  Turn the party base on.  Turn the camera on.  Turn the camera's flash off.  Using electrical tape, cover over the amber camera LED that wants to "help with the focus."  Make sure the camera is in smile detection/party base/never turn off mode.

It still doesn't work.  The party base "knows" that it is hanging sideways in the air.  With your fingers, apply a small amount of pressure to the rotating part of the party base.  When the base has been "fooled" into thinking that it is sitting on a tripod or table, it will be happy until the next turn on cycle.

Now, you can expect 95% or better accuracy in detecting smiles when someone is standing in front of the camera.

Enjoy!