3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Mechanized Android Figure

Step 8Software

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.

« Previous StepDownload PDFView All StepsNext Step »
3 comments
May 5, 2011. 1:32 PMsirius00 says:
Compliments for the gadget, I with AVRStudio I can not convert the file.asm.in hex to program the chip. You can send by mail? Thanks
May 19, 2011. 12:43 PMsirius00 says:
many thanks, I have prepared all the electronics, I'm waiting the micro servo, when I finished the Android will send you the photo
Apr 11, 2011. 2:54 PMmpound says:
What's the grey box you're using there to connect to the computer with? I'm a complete newbie to this whole thing so I'm just running through the instructions a few times to get prices for everything.
Apr 11, 2011. 4:22 PMawinograd says:
He's using the AVRISP mkll (http://parts.digikey.com/1/parts/408608-programmer-avr-system-atavrisp2.html).
Apr 12, 2011. 5:13 AMmpound says:
Ah-hah, thank you! :)

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
19
Followers
1
Author:tanabata