I used to be an eletronician before starting the IT college. I had my own electronics maintenance office to fix television, radios, etc. In my free time I used to create electronic projects to sell and I made a few "reais" selling a version of Dancing lights, but it was too limited: it simply animated lamps using a relay in the output of a 4017 CMOS IC. The circuit was a decimal counter controlled by a 555.
|4017 decimal counter. Source in the image|
When I met Arduino a few years ago, I was skeptical because I said: I can do this with IC, why should I use a microcontroller. I thought that Arduino was for kids. But now my pride is gone and I am having a lot of fun with Arduino :-)
The implementation of Dancing Lights with Arduino uses an electret mic to capture the sound and light leds according to the sound peeks(amplitude). The program also has the automatic way, that simply animate the lights without following the sound peeks.
Electret mic and preampI first tried a circuit with LM 741, but it was not working correctly (probably I did something wrong) and it used too many components, so I stick with a transistor preamp.
I connect the output of this circuit to an Arduino analog pin and read the input. Remember the analog input converts the signal into integer values between 0 and 1023. So we have to read this integer and using an IF to turn on the LED PINs according to the value:
|Analog Value||PIN set to HIGH|
|0000 - 0150||LED1|
|0150 - 0300||LED1, LED2|
|0300 - 0450||LED1, LED2, LED3....|
I am using 7 leds only, I need extra pins to control the automatic dancing lights. Notice also that I am not adjusting the gain of the circuit, but in future I plan to make a version with a potentiometer to allow it.
The single transistor circuit to amplify the input coming from an electret is the following::
|Simple circuit to pre-amplify an electret input. Source http://www.instructables.com/id/Pre-amp-to-electret-mic/|
Automatic Dancing lights
That might be the case when you don't want to follow the music, in this case, you can set Arduino to use automatic animations. A PIN will control if the circuit should whether follows the music or play automatic animations. If we select to play automatic animations, a String will be read from the serial port in order to load a new animation. Once we change the mode, it counts to ten seconds so you can write the code to configure the animation in the serial input. Think about the possibilities: you can use the same circuit to animate your Christmas tree or to rock a night house :-)
I also made a video(explanation in Portuguese):
In the next post I will discuss the Arduino code as soon as I clean it :-)