quinta-feira, 15 de janeiro de 2009

Tinkerlog - Blogue a visitar

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.

Tengu clone

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.

Sound sensor with 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.

  1. /*
  2. * Monitor for sound sensor
  3. */
  4. int potPin = 2; // select the input pin for sound sensor
  5. int ledPin = 13; // select the pin for the LED
  6. int val = 0;
  7. int amp = 0;
  8. void setup() {
  9. pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
  10. }
  11. void loop() {
  12. val = analogRead(potPin);
  13. amp = (val >= 512) ? val - 512 : 512 - val;
  14. if (amp > 100) {
  15. digitalWrite(ledPin, HIGH);
  16. delay(20);
  17. }
  18. else {
  19. digitalWrite(ledPin, LOW);
  20. }
  21. }

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.

tengu clone

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

Sem comentários:

Electrónica

Donde Vem

Downloads

Murros no Estômago

Tecnologia IG Brasil

Baixaki - Downloads

Technow