These Android figures are cute, but they don't actually do anything. Let's change that. Have a look at the video:
These are the steps to make an Android that reacts to sound, moves it's head, sends out Morse Code messages and displays some cool light patterns. In the video the LEDs in the body are not that visible, but this is what it looks like:
Step 1: Parts and Schematics
These are the required parts:
1 x Android Figure from DYZPLASTIC
1 x ATtiny44A from Mouser or Digikey
1 x 14 pin DIL socket e.g. from Digikey
1 x Micro Servo SG90 (plastic) or MG90S (metal)
1 x Microphone e.g. CMC-5042PF-AC from Digikey
1 x Piezo (passive, not the buzzer kind)
2 x blue 5mm flat top wide angle LED from ebay
1 x red super bright 5mm LED
1 x green super bright 5mm LED
1 x yellow super bright 5mm LED
1 x NPN Transistor e.g. 2N3904 from Digikey
2 x Rectifier e.g. 1N4003 e.g. from Digikey
1 x 100uF electrolytic capacitor
3 x 100nF ceramic capacitor
2 x 100K resistor
2 x 10K resistor
2 x 2K2 resistor (or other values depending on your blue LEDs)
3 x 150 resistor
1 x +5V power supply (e.g. USB charger)
There are many different versions of the Android figure. If you want to have LEDs inside the body, it is probably best to choose a light colored Android. Darker ones might block the light shining through too much.
For the eyes I used super bright wide angle 5mm flat top LEDs. They are actually too bright, so I used some larger resistor values to adjust for that. Try different values until the maximum brightness is to your liking.
I used a Mystery SD90 servo with plastic geras. After 2 months of heavy use it wore out. I have now replaced it with a T-Pro MG90S which has metal gears. It is more noisy, but hopefully that one will last.
A +5V USB phone charger makes a nice power supply.
To program the ATtiny44A micro controller you can either use an official Atmel programmer like the AVRISP mkII or one of the many third party programmers.
Step 2: Electronics Assembly
It is good to put the MCU and the microphone amplifier on two separate boards. This makes it easier to cramp them into the round Android body next to the servo. It is possible to add a 6 pin programming header to the MCU board. But again, for space reasons it is better to just make a separate programming adapter board with just the header and a socket.
Try to keep everything as small as possible. Solder the resistors directly to the LEDs. There is more space inside the Android.
Step 3: Open Android
Removing the head from the body can be quite hard. It requires substantial force. Take a look at the picture of the removed head. The rim in the front and the back of the head is flattened. Work from the back, so that any damage from opening the figure will not be visible from the front. Also take care not to accidentally break the antennae during the process. If you are having a hard time getting the head off, maybe warming the plastic could soften it a bit. I have not tried this though.
Step 4: Modify the Body
We do not want to have to do that again! So the next step is to cut off most of the head's rim. This will make it easier to take it off and put it back on. But the head still needs to be held securely while turning. So do leave some of the rim to the left and right. It helps to mark the center with a pencil first.
The head needs to be able to rotate easily. Trim off about one millimeter around the inner edge of the body.
Step 5: Prepare Head for Servo
Next prepare the head for the servo. Mark the cutouts with a pencil and try to keep everything as centered as possible. Cut two grooves into the front and the back of the head's rim.
Step 6: Install Servo
Cut off the small pieces at the side of the servo that are normally used to hold it in place. Instead use hot glue applied to the bottom of the Android figure. The servo head cross helps with centering. Make sure the servo reaches up far enough to reach the grooves in the head. If things don't quite fit the first time around don't despair. The hot glue can be removed quite cleanly and you can try again. The SG90S is slightly taller than the SD90 and fits a little better. It can just rest on the bottom.
Step 7: Install Electronics
Push the electronics to the side of the servo. Make sure the servo head can turn freely and that it's center position is to the front and back. The three body LEDs go to the front and are secured with hot glue. The same goes for the two eye LEDs in the head. Make sure the wires are tucked in securely.
The power comes in from the back, for instance into one of the feet. For better stability cut off the USB connector and use thinner, more flexible wires for just the power.
You may want to drill a few small holes where the microphone and piezo are located.
Step 8: Software
The software is written in assembler. The LEDs are controlled by five 100 Hz interrupt driven software PWMs. LED brightness is not perceived linearly. A lookup table helps to compensate for that.
The servo is controlled by a 50 Hz software PWM. Servos from different manufacturers have slightly different PWM pulse width min/max values. It is important that these are adjusted accordingly. Otherwise the servo may get damaged if it is driven repeatedly over it's limits.
The piezo requires a frequency in the kHz range. The AVRs hardware PWM is used to drive it.
One of the ADC channels is used to read the output from the microphone amplifier. When a certain threshold is reached, the head movement is triggered. Different microphones have an impact on the output of the amplifier. The trigger level can be adjusted in software. Mine is set so that it ignores normal conversations, but get's triggered when things get excited. It's also a good sneeze detector. :-)
The ADC is read from an ADC interrupt. If this interrupt handler is active while the PWM timer interrupt fires, it can introduce a slight jitter to the PWM. This jitter may cause the servo to move a little, which produces enough noise to trigger sound detector. There are two possible solutions to this problem. One would be to not use an interrupt for the ADC and read it in a wait loop instead. This can be a bit tricky and ugly. Instead the current solution is to simply disable the servo PWM pulse while the head is not moving. This will turn of the motor, save energy and PWM jitter will not cause any problems. In general the sound detection is only active while the Android is quiet, as any Morse code beeps or head movement would also trigger it.
One of eight Morse code messages is played at random. Wikipedia has a great Morse Code article. The Morse Code alphabet is encoded in a table which translates ASCII characters to the corresponding Morse signals using a two bit encoding. The actual Morse Code messages can therefor be stored in easy to read and space efficient ASCII strings.
The source code can be compiled and programmed into the MCU wit the free AVR Studio IDE. There are open source alternatives as well.
Step 9: The End
I hope you enjoyed this Instructable. There are many ways to improve or extend this Android. Or you can build Androids that do something completely different. Let me know what you come up with!