Archive for May, 2007

Cheap Sound Sensor for AVR

Sunday, May 20th, 2007

I searched the web for a cheap method to let the ATmega respond to sound. My knowledge in analog circuits is very limited, but what I do remember, is that you can not attach a electret mircophone to a controller pin. The signal of the microphone is just too small and has to be amplified. There is much of information out there, especially on diy amplifiers. I stumbled upon this little circuit here. It consists only of a handful of components:

  • 2 resistors 10k
  • 1 resistor 100k
  • transistor 2N3904
  • 2 capacitors 0.1u
  • electret microphone

Prototyping the amplifier

Putting things together on a breadboard.

IMGP1255

Actually I had no 2N3904 around, so I replaced it with a BC337. The circuit is a emitter circuit with voltage degeneration (I dont know if that exists in english). I dropped the couple capacitor and took the signal right away at the collector.

Prototyping with the ATmega

The sound sensing is done with the ADC of the ATmega. A simple program reads the analog value of the amplifier over and over. If the value (loudness) exeeds a specific level, an LED is lit.
IMGP1253

The schematic for rebuilding.
mic-schematic

The code can be found here mic_sensor.c. It is just hacked together and has lots of room for improvements.

Video

Here is a video that I made. Has lousy quality, for both, video and audio.


Click To Play

Conclusion

It was easy and worked pretty well. I enjoyed looking at the LED responding to the music. I haven’t recorded anything with this amplifier, it might sound awfull. Next steps could be playing the sound back or be able to analyze the sound (FFT). And (re-)learning more on analog circuit design.

Links

Synchronizing Fireflies

Friday, May 11th, 2007

I was always fascinated by the emergence of patterns. One I like most is the synchronization of hundreds or thousands of fireflies. First they flash randomly but after some time and influencing each other, they flash in sync.

The rule behind this is very simple. All fireflies have nearly the same frequency for their flashing, but their phase is shifted. If a firefly receives a flash of a neighbour firefly, it flashes slightly earlier.

This circuit simulates fireflies with small microcontrollers.

A single Firefly

The board consists of 25 fireflies. Every single firefly is self contained, there is no over-all controller. A single firefly consists of:

  • ATtiny13 microcontroller, 1k SRAM, 64 bytes RAM
  • Light Dependant Resistor (LDR)
  • LED
  • 2 resistors

IMGP1171

The circuit is the same as for the Programmable LED.

The complete Board

Assembling 25 fireflies on a prototype board is easy. Harder is to get the right distance between all fireflies. It has to be close enough to let one firefly influence another, but not the whole group.

The LEDs I used emit the light mostly straight up. So a kind of reflector is needed. I used a piece of paper which is located 5 mm above the LEDs. For the next version I would take LEDs with a wider light emitting angle and use a kind of diffuser, as proposed by Tod for his Smart LED Prototypes.

IMGP1200

Here is a video. It is a bit dark as my camera is not very suitable for this.


Click To Play

Links

Programmable LED

Wednesday, May 9th, 2007

Inspired by various LED Throwies, blinking LEDs and similar instructables I wanted to do my version of an LED controlled by a microcontroller.

The idea is to make the LED blinking sequence reprogrammable. This reprogramming can be done with light and shadow, e.g. you could use your flashlight.

How is it done?

It consists of an LDR, an LED and a tiny microcontroller. I used a ATtiny13v which is able to run with 1.8V. That makes it easy to power it with smallest batteries or even fruits.

schematic

Prototyping

All components can be easily used on a breadboard. Be aware, that you will need a separate programmer or an ISP adapter to program it.

The final version

The final version is powered by a CR2032 cell. It should have enough power for at least two weeks, depending on the light sequence it plays.

I have done a step-by-step instructable here.

IMGP1144

Here are some responses to the instructable

LED Clock

Saturday, May 5th, 2007

So this is my approach of an LED clock. There are zillions of LED clocks out there. Mine is some kind of retro and minimalistic version. It consists of

  • AVR ATmega8, 8 Kb, 4.096 MHz
  • Everlight 2.3″, LED Matrix, 8×5 LEDs
  • some resistors, capacitors and a quarz
  • optional serial connection for configuration

The LED matrix is used in landscape mode, that means it uses a very tiny font. Most characters fit in 3×5 pixels. The font supports only uppercase characters. Because the display has only 8 columns the message has to scrolled.

The display has the following features at the moment:

  • Displays a greeting message
  • Displays the current time, hh:mm:ss
  • Displays a custom message
  • Messages and current time can be modified via serial port

IMGP1238

Schematics
Here is the schematic of the LED clock. The Everlight 5*8 Dot Matrix was not available as part of the Eagle libraries, so I build the part on my own. It looks a bit clumsy as it is my first try to design components.

schematics

Here is a video of the LED Clock. You can see how it changes through different modes from telling the time to displaying a greetings message.

Click To Play
Click To Play