When I first saw Crispin Jones Tengu, I was sure, I must have one. If you don’t know tengu and don’t want to follow the link, it’s a small face, made of LEDs, that reacts to music and sound.
It did not take long until I decided to clone this funny little device. All it needs is a microcontroller, an LED matrix and a sound sensor.
Parts
- ATmega48, 4kb flash memory, 512 bytes main memory
- crystal, 10 MHz
- Everlight 8×5 LED dot matrix display
- electret microphone, taken from an old mobile phone head set
- LM386 op-amp
- 5 x 1k resistor
- 1 x 100k resistor
- 1 x 10k potentiometer
- 1 x 100k potentiometer
- 3 x 0.1u capacitor
- 2 x 22p capacitor
All parts should be available for less than US10$.
Sound sensor
To get a good and robust signal out of the microphone, an amplifier is needed. I found an really easy schematic of an amplifier at Jose Pino’s site. It is based on the LM386, an op-amp, often used in small music amplifiers, e.g. Cracker box Amp in Make 09.
I assembled it on a small breadboard and tested it with my new Arduino.
It worked great, but I had to use an alternative power source. When I used USB as power supply, the on- and off-switching of the monitoring LED lead to additional noise. 4 AAA cells solved that problem. For the first test you can use a small speaker attached to pin 5 of the LM386. Be sure to add the 220u capacitor between the LM386 and the speaker as shown in the schematic, otherwise you may blow your amplifier.
Here is a little sketch, that I used to test the sound sensor.
/*
* Monitor for sound sensor
*/
int potPin = 2; // select the input pin for sound sensor
int ledPin = 13; // select the pin for the LED
int val = 0;
int amp = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin);
amp = (val >= 512) ? val - 512 : 512 - val;
if (amp > 100) {
digitalWrite(ledPin, HIGH);
delay(20);
}
else {
digitalWrite(ledPin, LOW);
}
}
Controller and LED matrix
The Everlight LED matrix with its 40 LEDs is big enough to display a small face. The matrix needs 5 1k resistors for every row to limit the current.
The sound and its amplitude is sampled by the ATmega48 with one of its analog input pins (ADC). Then the suitable face is choosen to display. The faces are stored as simple bitmaps.
Conclusion
This small thingy is fun to watch. And it was fun to build. Maybe I’ll try to put it on a prototype board to be able to carry it around.
Yes, I know. My camera sucks.
Links
Downloads
- tengu_clone.zip, source, hex and Eagle schematic



Du bist ein Spielkopf und solltest lieber in einer E-Technik Bude schaffen gehen wie ich früher :-) Ich finde das Ergebnis erstaunlich gut – Respekt !!!
LikeLike
Nice project. Your track selection was superior as well. Congrats on getting on “hackaday”.
~~Andrew
LikeLike
That’s pretty neat use of a LED matrix. I might see about doing something like that myself. I currently have a 8×8 bicolor LED matrix hooked up to an AVR, so far I’ve written a simple pong game.
A video is included here: http://blog.davr.org/2007/09/24/avr-project-update/
LikeLike
Wow! I must make one!
I have been looking for a “light organ kit” for a while. This is it for sure.
nice work.
LikeLike
Let me know if you ever do a PCB layout for the whole thing.
cheers,
steve
LikeLike
Is the Arduino and integral part of the project or was it just used to test it out? I’d like to get started in microcontrollers and I’m wondering whether it’s better to order an arduino or a programmer and some chips to tinker with.
LikeLike
Hi Seb,
I used the Arduino for testing only. Nevertheless, the complete Tengu could be build with the Arduino.
If you are trying to get started with microcontrollers, I would recommend to use the Arduino, because it’s really easy to get things going. No programmer, no soldering, only a breadboard to assemble your first cicuits.
Cheers,
Alex
LikeLike
Thanks for the reply. I think I will order an Arduino. Am I correct in assuming that if I use the Arduino as a testing ground for a project, that once I have things working the way I want, I can use the code on a standalone chip, in its own circuit? Basically, the Arduino is so that i don’t have to build a voltage regulator or connections or whatever else is needed for a microcontroller to function in a circuit, everytime I want to tryout an idea. Is that an accurate assesment?
LikeLike
Seb,
the Arduino uses a C as a programming language with some libraries, based on Wiring. If you want to use another micro for your final project, you may have to adapt your code.
Cheers,
Alex
LikeLike
Alex,
Thanks a lot for your responses, you’ve been very helpful.
LikeLike
This is awesome stuff. I am thinking about getting an Arduino for christmas and this is the first project I want to build. What needs to be adapted from your design for this project to work on the arduino? I have never done any “electronics” stuff before and wanted to know if you could make a more detailed writeup of your procedure. im just wondering, but yeah this project is super awesome.
LikeLike
Hi David,
if you are absolutely new to electronics, I would recommend to start with an Arduino and a breadboard to build the first simple things. Have a look at Boarduino: http://www.ladyada.net/make/boarduino/
After that, take a look at the schematic above. Everything right side of the ATmega is needed for the Arduino version. Additionally the code has to be adapted. Reading the sound sensor is straight forward. Programming the LED display may be a bit harder.
I am not sure, if I find time to do a Arduino version of this. We’ll se.
Cheers,
Alex
LikeLike
Thanks. What are the advantages of using the Boarduino and the Diecimella Arduino? From what I gather, couldnt you just “jumper” the arduino to a breadboard?
LikeLike
Hi David,
yes, you could “jumper” the Arduino to the bredboard. But if you did that once or twice, you would love to have an Arduino that sticks to the breadboard.
Cheers,
Alex
LikeLike
I’m looking at your sound sensor, and I just want to know what parts are being used in the sound sensor/amp part. I think this would be a great instructable :D
LikeLike
Hi David,
if you take a look at the schematic, all parts that are at the top are needed. There is a single wire that connects the amplifier with the microcontroller.
Cheers,
Alex
LikeLike
i did look at the schematic earlier, but I was confused because in the schematic you show a 220u capacitor and a speaker. Both not listed on the parts, and the only question I have now is what is the speaker component?
So far my dive into microelectronics has been good. I’ve been collecting parts, and have been testing out things on the breadboard. Thanks for all teh feedback.
LikeLike
David,
the capacitor and the speaker are used for a first test of the amplifier. They are not need for the final circuit.
Cheers,
Alex
LikeLike
Hey Alex, this is a cool project. Thanks for sharing! Sorry for the off-topic, but what wordpress plugin do you use to display the source code?
LikeLike
Hi Mark,
check out the “?” at the top of each source code section.
Or have a look at: http://code.google.com/p/syntaxhighlighter/
Cheers,
Alex
LikeLike
Hi,
Awesome project. Any chance to sent me the already compiled HEX file? I tried to compile it and program it, but the only thing I got is all the leds lighten up dimmly… :-( No face!!
Regards, Thanos
LikeLike
Oh, and something else, I used a ATMega88 as I could not find ATmega48 here in Greece easily… Do you think that makes a difference?
Regards, Thanos
LikeLike
Hi Thanos,
I zipped it again and put the hex file into it. Please try it.
Have you tried it on a breadboard? That will be easier to track down bugs in that setup. Try to activate a single face and see if that will light up.
The ATmega88 is pin compatible with the ATmega48. But I am not sure if it will work.
Cheers,
Alex
LikeLike
Hey:
I put the amp+mic portion of the circuit together, and hooked it up to my arduino. However, all I get is an led that stays on.
David
LikeLike
Hi David,
please check if the mic is connected the right way. It has a polarity so you might want to try it the other way round.
Next thing would be to hook up a multimeter at the output pin of the amplifier and see if it changes its value when you shout or touch the mic. Also try to adjust the potentiometers for amplification and volume.
I used a small speaker to “debug” the circuit. For that you will need the 220u capacitor.
HTH.
Cheers,
Alex
LikeLike
Hello Alex, using your experiment as a base, I have developed my own PCB Tengu using a PIC microcontroller.
This video is a brief presentation of PIC-Tengu (http://www.youtube.com/watch?v=MnFP4FNVE-I). It is in spanish but subtitled in english.
Thank you very much for your inspiration; I have enjoyed very much developing ti.
LikeLike
jfmateos2,
man, this one is fantastic. Really good work, much nicer than mine one. Thanks for stopping by.
Cheers,
Alex
LikeLike
Nice project. I want to make this on a uC board that I already have. It has an LCD screen, a microcontroller and a built in microphone. Is there anything I would need to modify or add to get this to work?
LikeLike
Hi Shevy,
that should be sufficient to get everything to work. Be sure to get a signal out of the microphone, that is strong enough to measure it with the microcontroller.
Cheers,
Alex
LikeLike
Hello,
I was trying to order Atmega48P, but finally they sent me Atmega48 in TQFP, same but diferent pinout and SMD format.
I have adapted pinout and assemble all components, but Only I get is all leds lights.
I have double cheked all, and looks like all right.
Any advice?
What compiler do you recommend to make some changes in .c and after compile to program via ISP?
Thanks and Good job. :)
LikeLike
Hahahahahaa….
I answer myself
Stupid mistake, I made the Led Matrix in wrong way, Anode where Cathode and viceversa, the strange thing is all led lights :)
Thanks anyway and best regards.
LikeLike
Hi Alex,
Cool project!
Q1. When i compile the script above i get:
In function ‘void loop()’:
error: ‘val’ was not declared in this scop
Q2. Can i connect my computers audio output directly on input pin 2 or do i have to use the opamp circuit?
Thanx
LikeLike
Hi Mookie,
I corrected the error above, it should work right now.
If you can connect it directly to your audio output, I am not sure. If the output is inbetween 0 and 5V then it may work.
Cheers,
Alex
LikeLike
Alex, how do you know the AC offset will be 2.5V, on the audio signal?
I see you are assuming this with the hardcoded ‘512’ in
“amp = (val >= 512) ? val – 512 : 512 – val;” line
also, why the .1uF Cap on the Amp? All the circuits i’ve see use a polarized 10uF for a 200X Gain or nothing for 20X, are you trying to do a custom gain? The reference circuits use a 1.2K Resistor and a 10uF (unpolarized) Cap. for a 50X gain.
thanks so much great work!
LikeLike
Hi Brady,
if I recall it correctly, I was using the Arduino to test the circuit. With it I was monitoring the values from the amp.
And yes, I think you can choose your amplification with the caps. My worked fine with 100nF.
BTW, I am an absolute audio noob ;)
Cheers,
Alex
LikeLike
have you tried making this into a daft punk style helmet? that would be cool.
LikeLike
Hello there. I got some 8×8 red matrix lying around. Any hint how i could possibly modify the script to work with 8x8s ? This is so great, i will build for my son in toy. Thank you!
LikeLike