Introduction: Sound Into Light Shows
This is how to make a Magical Music Box which converts sound into a light show. When i was daydreaming what to make, i wanted something that would make a light show for any song simply by hearing it.
(include a video here)
Real simply, i used a microphone circuit for input, amplified it, ran it threw a potentiometer so i could control how senstive it was to ambient noise then split it into 3 band pass filters to tune out other frequencies then used that as an input for my arduino. A simple conditional based on that input controlled 6 digital out pins with each pin connected to a single input on 2 separate red, green, blue LED’s. So since each LED has 3 inputs, thats 6 pins to control 4 RGB LED’s.
I ran everything off of 2 nine volt batteries, one as +9v and the other as -9v. I included a simple power schematic. I used the arduino for all my grounds.
This is your overall shopping list. In each section i will let you know what parts you need from this list but don't get confused and think you need more parts. This is the complete listing of all parts needed to make this project.
NOTE: if you make changes to the parts list, i'll try to detail how this affects the overall process in each section but no promises on the end result if you do
1x arduino (of any type, the code is pretty light stuff)
8x 1k ohm resistors
5x 10k ohm
7x 560 ohm
3x 150 ohm
4x RGB LED’s
8x 0.1 uF ceramic capacitors (this saves you trouble later since you don't have to worry about anodes and cathodes on these types of capacitors)
2x LM358N op amps
1x LM386 Audio Amp
1x microphone sensor
2x 9v batteries with battery holders
approx 2 miles of wire (just kidding but it seemed like a lot)
some kicking music to show off with
Step 1: Microphone Circuit
This is a simple microphone circuit. I got this part of the over all schematic from whyameye. For this section, you will need:
LM386 audio amp
0.1 uF capacitors x3
47 uF capacitro x1
Microphone sensor x1
10k Ohm resistor x1
1k Ohm resistor x1
In the schematic below, i've marked off the top left corner and if you mouse over it, it will say its the mic circuit. This is the section we will be building. First, find a section of bread board with at least 8 rows open on both sides. Since the LM386 takes up 4 rows center it in the open section you select.. This leaves 2 rows on either side that you will need later.
(include a picture of the amp centered on the open section of bread board)
Now, before we can put anything else on the bread board, we need to find out which side is the "top". The audio amp will have a small cut out shape on one end. Mine was a half circle. If you did it just as i have, then pins 1 and 8 will be in row 3 of the breadboard. If you did it differently for whatever reason, just be sure to adjust for that when i refer to specific rows later.
(include picture here of this far in the process)
- Connect pins 2 and 4 to ground. Pin 6 connects to +5v.
- Connect pins 1 and 8 together with your 47uF capacitor, making sure the anode (the longer lead) is connected to pin 1.
- Connect one side of a 0.1 uF capacitor to pin 3 and the other to row 2 on the left side of the bread board
- Connect one side of the 10k Ohm resistor to row 2 and the other side side to +5v.
- Connect the left side of row 1 on your bread board to ground.
- Connect the anode of your microphone circuit to row 2 on the left side of the bread board and the cathode to row 1, also left side.
- Connect one side of a 0.1uF capacitor to pin 6 and the other to row 7 right side.
- Connect row 7 right side to ground
- Connect one side of a 0.1 uF capacitor to pin 6 and the other to row 8 right side.
- Connect one side of a 1k resistor to row 8 right side and the other to ground.
Row 8 right side on your bread board is your out put for your microphone circuit.
I feel that testing during creation is important to make sure you are getting an expected result. I'll cover that in the next step.
Step 2: Amplification Circuit
This is the amplification circuit. I added this because it was not sensitive enough to sound for my personal taste. Refer back to the main schematic. This section is located in the upper right and it says its the amplification circuit when you mouse over it.
The LM358 is a dual op amp, meaning that it has 2 amps on a single chip. If you chose to use a different amp for whatever reason that is only a single op amp you will need 4x total amps instead of 2 as i origanally stated at the beginning of this document. You will also need to adjust the pins. In fact, this whole section will be pretty useless to you except for the schematic.
First lets place our op amp on the board. Since i'm planning on using the other side of this dual op amp for a filter circuit i will give it space sufficient for a filter circuit. (thats 10 rows minimum, more rows makes things neater).
For the resistors on the amplifier circuit, i chose to stick with the ones i was using on my filter circuits. i'm not sure if the same rule applies to these as to R1 and R2 on the filters schematic but since that works, i chose to just stick with something that i knew worked. I used a 720 Ohm and 1k resistor. For more about selecting these values, refer to the step on the filter circuit in this document.
- Connect the output of your microphone circuit to pin 5.
- Connect Pin 6 and Ground using the 720 ohm resistor
- Connect pin 6 and pin 7 using the 1k ohm resistor
Pin 7 is your out put for the amplification circuit. I fed this to my potentiometer.
Step 3: Filter Circuit
I used the PDF titled "Op Amps for Everyone" by Texas Instruments to learn how to make a band pass filter. Specifically i used the Sallen Keys band pass filter located in section 126.96.36.199
The op amps i used were LM358N, which are dual amps. this was very nice when i was putting my circuit together since i only had to use 2.
I chose this specific circuit because of its simplicity. The formula’s to select a frequency, quality (bandwidth) and gain are pretty simple in comparison to others but you pay for it since gain and quality are interlinked. Since this was my first attempt at making a band pass filter, i chose simple over versatile. I selected 110hz, 440hz and 1760 hz as the target freq’s for my filters. I’ve also included a simple spread sheet i made so you can select the frequency you want to tune your filter for by adjusting the capacitance and resistance of the circuit.
The bare minimum of space needed on your bread board is 10 rows. if you chose to spread your circuit out (which i advise during initial building and testing) just adjust accordingly when i mention a specific row.
Since i already used one side of the first op amp for the amplification circuit, i used a different bread board layout for each one. First i'll cover the other side of the op amp i used for the amplification circuit.
I place my chip with pins 1 and 8 on row 6. Refer to the microphone step to find out how to find which pin is which. This will put the eventual input of the filters closer to the amplification circuit.
(include picture here)
Now for the other op amp layout.
Step 4: When Life Isn't Ideal....
Unfortunately, i was unable to get my band pass filter circuits to work out ideally so i had to test them to see what they were actually doing and thats what i’ll cover next. For this part i used a frequency generation program with sweep capability as my input that whyameye wrote for me using his favorite toy, the PD environment. I wanted to use a spectrum analyzer to check the output but since i didn’t have one i subbed in an oscilloscope. Since there are whole manuals about how to use an oscilloscope, i won’t cover how to use one here.
To test an audio circuit using the above tools, you need to have a working microphone circuit. i hooked my oscilloscope to the output of the mic circuit then just talked into it to make sure that the microphone was actually “hearing” it. You should see the level increase as you talk into the mic and go down as silence takes over. Once i was sure my mic circuit worked, i fed the output of the mic into the input of the filter i was testing and moved my oscilloscope test point to the filter output. this time instead of talking into it i used the sweep function of the frequency generation program. make sure and set your sweep time high (relatively for an oscilloscope) i chose 2 seconds. since your sweeping threw the selected frequency range while maintaining the same volume level, any differences you see in amplitude are differences in amplification at those frequency's. you should see some sort of "high point". this is when i discovered that my circuits were not filtering for the frequency’s i had thought, however they were performing as band pass filters. i was basically using an arrow head shape.
Step 5: Arduino
I used the basic analog read serial program as a starting point for my arduino code. I have 3 basically indentical modules, one for each analog input connected to a filter. I stored the analog read value then used IF statements to compare the analog read value to the old analog read value checking for a 10% differeance higher or lower. Finally i made the old analog read value equal analog read value with that being the end of the loop. I’ve included my code at the end of the post for your viewing pleasure.
The RGB LED's have + voltage as the common pin so the different colors can be triggered on when the state of each pin reads "LOW", which i substituted as ground.
IMPORTANT NOTE: i included a 1k resistor on the +5v going to the LED's because when i connected them to the rest of the circuit i was getting a lot of spiky noise threw out the whole circuit.. this is not included in the parts list or the schematic.
Step 6: Credits and Future Improvements
I couldn't have done this without Tom McGuire and John Harrison
1) use filters that can work with potentiometers so the filter can be tuned instead of trying to find the perfect resistors.
2) use a smaller potentiometer on the amplifier output level to control ambient sound sensitivity better
2.1) put potentiometers on each filter output so that they are all the same level when they reach the arduino. this will assist in implementing a threshold
3) write an easily controllable threshold into the code so that its even more selective for the frequency’s i picked.
3.1) an led that displays impedance of the pot controlling the threshold
4) i wanted (and still do!!) to find a way to split a laptop wall adapter into + and – voltages so i can stop using batteries.
5) i'm not sure if its possible but maybe a fade based off of amplitude?