Pular para o conteúdo principal

Dancing lights with Arduino - The idea

I have been having fun with Arduino these days! In this article I am going to show how did I use an electret mic with Arduino to create a Dancing Lights circuit.

Dancing Lights 


 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 preamp

I 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 ValuePIN set to HIGH
0000 - 0150LED1
0150 - 0300LED1, LED2
0300 - 0450LED1, LED2, LED3....
An so on...

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 :-)


Conclusion

At this moment I haven't finished the circuit, I haven't even started it to be honest :) Once I finish it I will publish this post and make another one with the technical details and show how to expand it to turn on lights instead LEDs. In another post I plan to create a JavaFX application to monitor the LAMPs and allow to change the selected animation.

The circuit is working! See how it looks like:
I also made a video(explanation in Portuguese):



In the next post I will discuss the Arduino code as soon as I clean it :-)

Comentários

Postagens mais visitadas deste blog

Genetic algorithms with Java

One of the most fascinating topics in computer science world is Artificial Intelligence . A subset of Artificial intelligence are the algorithms that were created inspired in the nature. In this group, we have Genetic Algorithms  (GA). Genetic Algorithms  To find out more about this topic I recommend the following MIT lecture and the Nature of Code book and videos created by Daniel Shiffman. Genetic Algorithms using Java After I remembered the basics about it, I wanted to practice, so I tried my own implementation, but I would have to write a lot of code to do what certainly others already did. So I started looking for Genetic Algorithm libraries and found Jenetics , which is a modern library that uses Java 8 concepts and APIs, and there's also JGAP . I decided to use Jenetics because the User Guide was so clear and it has no other dependency, but Java 8. The only thing I missed for Jenetics are more small examples like the ones I will show i...

Simplest JavaFX ComboBox autocomplete

Based on this Brazilian community post , I've created a sample Combobox auto complete. What it basically does is: When user type with the combobox selected, it will work on a temporary string to store the typed text; Each key typed leads to the combobox to be showed and updated If backspace is type, we update the filter Each key typed shows the combo box items, when the combobox is hidden, the filter is cleaned and the tooltip is hidden:   The class code and a sample application is below. I also added the source to my personal github , sent me PR to improve it and there are a lot of things to improve, like space and accents support.