In order to learn about servos, Max Maxfield decided to build a pair of animatronic robot eyes.
A few weeks ago, when I was having problems with one of my antique analog meters, someone suggested replacing the failed movement with a servo. Though I ended up taking a different path, this made me realize that I've never gotten around to playing with servos, so I decided to rectify this situation.
The first thing I did was to buy four micro servos from Adafruit.
I also purchased one of Adafruit's servo shields. This little beauty can control up to 16 servos, and it interfaces to the Arduino via I2C, which means it uses only the two I2C pins on the Arduino. This is no loss to me, because I always end up using these pins to talk to one or more I2C-based shields.
Now, the best way for me to learn something is to work on a project. I've always been enthralled by robots, so I decided to build myself a pair of animatronic eyes.
Once everything had arrived, the first thing I did was to characterize the servos, which can rotate through 180°. Adafruit's example sketch uses minimum and maximum pulse widths of 150 and 600 (out of 4,096), respectively, but these values didn't appear to give me a full 180° movement, so I whipped up the setup shown below.
Here we see my four servos numbered 0 through 3 from left to right attached to a strip of wood to stop them from wandering around. I used Visio to create circles marked out in 5° segments, and then I cut these out of paper and attached them to the top of the servos under the horns (the black pieces of plastic that convey the motion of the servos to other objects).
I then created a simple program that starts by setting all the servos to their middle positions. The RGB LCD Shield shown in the foreground of the above image includes five buttons: Up, Down, Left, Right, and Select. My program uses the Select button to cycle among the servos. The Up and Down buttons rotate the selected servo clockwise and counterclockwise, respectively. These buttons take the servo to approximately 10 degrees from its full-scale rotation in the selected direction. Then I use the Left and Right buttons to rotate the servo clockwise or counterclockwise a degree at a time until I determine the extent of its rotation.
In the above image, we see that, for Servo 3, the minimum pulse width is actually 114, as opposed to the default value of 150 found in Adafruit's Sketch. In fact, I determined that all four of my servos had minimum pulse widths of 114, but their maximum pulse widths varied between 580 and 588.
The next step was to create the eyes themselves. I did this using a couple of Ping Pong balls mounted on short wood dowels that I painted black. For the purpose of these preliminary experiments, the servos are mounted on a small platform made of balsa wood.
After setting the servos to their center positions, the dowels were attached to the horns on the servos using superglue. Small triangles cut out of balsa wood are used to provide extra support.
Now take a look at the test setup shown below. The animatronic robot eye platform is sitting on top of a plastic box. Below this to the left, we see the servo shield mounted on top of one of the screw-block proto-shields created by Duane Benson and yours truly. This proto-shield is mounted on top of an Arduino Uno.
Just to the right of the Arduino-Shield stack, we see my trusty RGB LCD shield. In the foreground are two 10KΩ potentiometers. I drew the black circles on the Ping Pong balls before attaching them to the dowels and attaching the dowels to the servos. What with "this and that," they ended up not looking straight ahead.
My next step was to create another simple program that uses the left and right potentiometers to control the position of the left and right eyes, respectively, and to display the corresponding pulse widths being fed to the servos on my RGB LCD. This allowed me to determine the pulse widths required for each servo to look directly ahead. Everything else is calculated as looking some number of degrees left or right of the center position.
Actually, I'm pretty pleased with the way things are coming along for this first attempt. Take a look at this video and let me know what you think.
My next move will be to add eyelids that blink. Each eye can move independently (as you can see from the "squint" in the video), and I want the eyelids to blink independently, so that the assembly can "wink" at you.
In the fullness of time, I can see (no pun intended) these eyes residing in a wooden box. Whenever there's a sound or someone walks by, the lid of the box could raise up slightly, and the eyes could peek out and track the person as he or she moves around the room. As an alternative, I was thinking of a Mad Hatter's top hat, with the top peeled back as though it had been punched out and these eyes peeking out of the top of the hat.
Can you imagine wearing this hat on Halloween -- or possibly sporting the little beauty while walking around the Embedded Systems Conference (ESC). In my mind's eye, I can visualize ambling past someone and the animatronic eyes at the top of the hat "locking stares" and tracking that person as I stroll by.
Of course, I'm just dipping my toes in the animatronic waters here. If you look on YouTube, you'll see that other people have created some really amazing and sophisticated systems. My eyes can only look left or right, for example, but some folks have their eyes looking left, right, up, and down. The great thing here is that this gives me something to aim at for the future. Watch this space (again, no pun intended).
— Max Maxfield, Editor of All Things Fun & Interesting