Every year my son's class builds Valentine's Day treat boxes to put each others' Valentines Day treats into. Last year in his kindergarten class, we made a simple box-shaped robot with a slot for the treats to go into. This year we decided to up the anty a notch and go with something a little more entertaining.
It started like this... The Saturday morning before Valentine's Day, I was informed my son needed to build his Valentine's Day treat box before Valentine's Day, which is only 5 days away. And with the way our family weekday schedule goes, that meant we only had Saturday and Sunday. Not too big of a deal for a plain Jane treat box, but who wants plane Jane? I started thinking, "what combination of LED's, motors, sound and, of course, a microcontroller would be cool, and yet be completed in one or two days?" Then it just kinda hit me. How 'bout a head that makes a sexy whistle, raises its eyebrows and has some flashing LED's for eyes...?
I hadn't the foggiest idea at that point of what anything would look like or how to make the eyebrows move up and down given the supplies I had lying around and what could be accomplished in a day. But I have a slew of microcontroller boards and was leaning towards the Arduino UNO as my first legitimate use of it. So, I figured the rest would come to me by the time I got that far.
I scrounged around in the basement, kitchen, and garage in search of something to use for its head... Lucky for me, my wife does a lot of baking, which has contributed to the delinquincy of my fitness. So, enter Hershey's cocoa tub...
The cocoa tub seemed like a good candidate as it was proportionately sized to the box my son had already picked out for the body, and it has a slight curvature on it's wide side.
To make the eyebrows move up and down, I needed a geared dc motor, servo or other electromechanical device. It would be easy to use two servos, one servo for each eyebrow, but I only had one servo in my organized pile of salvaged electronics. So, I needed to come up with a system of mechanical linkages and tie it to that one servo.
It was around this time the idea hit me for using paper clips to poke through the plastic tub and connect to the eyebrows. Still unsure what the eyes and eyebrows would look like or what they would be made from, I felt the paper clip idea was pretty solid. We seem to have paper clips laying astray at the bottoms of just about every drawer in our house, so if I screwed one up I could just toss it and try again.
Now, how to connect them so they move together and have one common linkage to the servo...? After I straightened and formed the "hooks" into the paper clips, I noticed the longer straight portion was more than long enough to reach across the inside of the tub and overlap each other. Using a pivot point at the midpoint between the to holes in the cocoa tub, I could attach a push rod, made from another paper clip of course, which would extend down to the bottom of the tub where the servo would be located. The long straight ends needed to be curled around the push rod so that the push rod wouldn't slide to one side or the other and fall off. Also, because a servo has a specified degrees-per-second speed rating, I needed to extend the radius of the servo hub. This way, relatively little rotation equated to a larger and faster linear motion. Using the servo's plastic hub by itself would have provided enough linear motion but would have required a good portion of the servo's entire range of motion, which means not-so-snappy eyebrow action. So this is what the end idea looked like (view from front of robot):
Next, I needed to figure out how to hold all this stuff together inside the tub. We needed to run a couple errands that afternoon, so I went to Hobby Lobby and found a block of styrofoam. This would be easy to cut and shape as needed to hold everything together and fit inside the tub. If you've ever worked with styrofoam, you'll already know to have a vacuum sweeper handy...!
Next I started thinking about what to make the eyes and eyebrows look like. I looked around on the net and found several builds with heart-shaped eyes. I figured this would do, and I could just cut off the two humps at the top, which would become the eyebrows. A little hot glue action and wha-la...
Now, every nerd knows no project is complete without some LED's for visual stimulation. But this is trivial and will be put off until the end.
At this point, I have a good handle on all the mechanical stuff for the eyebrows, time to focus on sound... I had a few different piezo transducers, so I plugged one into the Arduino UNO and started playing with the 'tone' library trying to get the right sound for the "cat call" (aka cat's call, cat whistle, wert whirl). After a good bit of fiddling around in the Arduino sketch (and driving my wife to wit's end), I finally came up with one I was satisfied with. It needed to be louder though, and where was I going to put it inside the tub such that it wouldn't interfere with the eyebrow mechanism? Here's where I started and ended up:
Finally, the LED's...! No biggy, but it had to be done. I punched a couple holes with the exacto, then had to solder leads and resistors onto the LED's. I swore I had some heat shrink laying around, but couldn't find it at the time (as I'm writing this blog entry I think I remember where it is...). My assembly methods turned out to be somewhat inconsistent (rosin fumes maybe?). I realized as I was soldering the LED leads that on one LED, I had formed the anode leg and the other I had formed the cathode leg. I'm not sure at all how this happened, other than my mind-brain was tied up with other thoughts at the time... So I resolved the inconsistency by being inconsistent with which leg the resistors were on, and then being consistent with the wire colors to LED legs. Makes perfect sense, right? LOL. So, I ended up with what's shown here, where the yellow is the cathode and the red is the anode:
As you might have noticed above, I had to trim about 1-1/2 inch off the top of the styrofoam block to allow room for the Arduino UNO, battery pack and other wiring that had to fit into the tub.
Next, it was time to add a mouth and stuff everything inside the tub:
I ended up making a cutout on the side so I could reprogram the Arduino without having to remove the top and risk damaging the wiring. I'm glad I did, because we found out after plugging and unplugging the battery (to save the batteries), the eyebrows don't restore to their "down" position. This is because "down" position is actually 110 degrees. This was due to another oops when re-mounting the servo hub onto the output shaft after the extension arm was added. Another example of the software guy fixing the hardware guy's mistakes :) Anyway, I didn't look at the underlying code in the servo library, but I suspect when the Arduino initializes and hits the myservo.attach code it initializes the PWM signal to 90 degrees, or "centered".
Overall, I like the way it turned out. Just need to glue it to the top of the body-portion of the robot. Some fancy treat box... :)
You can download the Arduino sketch
here.
Or use this command if you want to clone the repository:
hg clone https://clintastevenson@code.google.com/p/valentines-day-robot/