DIY Tengu on a breadboard
October 22nd, 2007 · 45 Comments · avr, led, sound
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 capicitor
- 2 x 22p capicitor
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 capicitor 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
Sem comentários:
Enviar um comentário