loading


This project shows you how to take inputs from a computer, MP3 player, or stereo via a headphone jack and get LEDs to respond and visually display the peaks and troughs of the music.

For this project you will need:
-One (1) ArduinoMega w/ USB upload cable
-Two (2) 10-Segment LED Bar Graphs
-One (1) breadboard
-A few feet of 22 gauge solid wire
-One (1) 3.5mm Male to Spade-Tongue Speaker Cable


Attached is a video of the finished project.

Step 1: Setting Up the Breadboard

For this step you will need:
-Two (2) 10-Segment LED Bar Graphs
-One (1) breadboard
-A few feet of 22 gauge solid wire

NOTE: For this project we used two 10-Segment LED Bar Graphs for a total of twenty individual LEDs. However, using just regular LEDs, either less or more, will work perfectly fine. The Bar Graphs create a cleaner look. Though we do recommend using at least five LEDs for the desiref effect to be achieved.

With the breadboard positioned vertically, insert the LED bar graphs vertically with each line of pins straddling the void traveling vertically up the breadboard so that the positive and negative pins of the bar graphs are on opposite sides of this void.  

Next, since wires are connected horizontally in breadboards, insert twenty (20) jumper wires into the plugs of the breadboard that are  horizontal to where the negative (for the bar graphs there is no predesignated positive or negative side, you get to choose) pins of the bar graphs plug into the breadboard. Then take each of those jumper wires and connect them to the negative bus of the breadboard on that same side.

Now, insert twenty (20) jumper wires into the plug of the breadboard just like you did in the previous step except this time insert them on the positive side of the bar graphs. DO NOT connect these jumper wires to the positive bus of the breadboard.


Step 2: Connecting to the Arduino Mega

For this step you will need:
-One (1) Arduino Mega
-One (1) longish jumper wire

Take each of those positive jumper wires and insert the free ends into the pins numbered from 34 to 53. IMPORTANT: Insert the bottom-most jumper wire into pin 34 on the Arduino, then the jumper wire DIRECTLY above that into pin 35, the pin DIRECTLY above that one into pin 36, and so on and so forth until you put the last jumper wire into pin 53. The reason for being so meticulous in inserting the jumper wires into the Arduino is because if the LEDs in the bar graphs are not connected to the )Arduino sequentially they either not light up in the correct order (if you use our code) or (if you program this yourself) it will make coding for this project more frustrating.

Next, insert the longish jumper wire into THE SAME negative bus on the breadboard as that you plugged the negative jumper wires from the bar graphs into. Then take the free end of this jumper wire and plug it into one of the two (does not matter which) ground (GND) plugs on the Arduino.

Step 3: Setting Up the Arduino to Take Inputs

For this step you will need:
-One (1) 3.5mm Male to Spade-Tongue Speaker Cable

NOTE: You can use any cable that will fit into a 3.5mm headphone jack. The reason for us using the specific cable we did was purely cost based. Using another cable will not affect the functionality of this project.

First, cut off the both of the spade-tongues on the speaker cable. Next, separate the two wires from each other and strip of approximately 1/3 of an inch of the insulation.

NOTE: Since the speaker cable is not made out of solid wire we suggest that you spin the threaded wire together so that it is easier to stick into the plugs on the Arduino which you will do next.

Now take one of the exposed ends of the speaker cable (does not matter which one) and insert it into the other ground plug on the Arduino. Then take the other exposed end of the speaker cable and insert it into ANALOG plug 8 on the Arduino.

NOTE: If you are using our code (attached in the next step) for this project you must use Analog plug 8 on the Arduino because it corresponds to our code. If you are writing your own code for this project feel free to use any plug AS LONG AS it is still an Analog plug.
,

Step 4: Upload Code to Arduino

If you have never used or programmed an Arduino, the required software can be found at:
http://www.arduino.cc/en/Main/Software
This website is also a great resource for learning how to write and troubleshoot your code.

Connect your Arduino to your computer with the USB cable. Upload the code to the Arduino.

Leaving the USB cable plugged into BOTH your computer and the Arduino (your computer acts as the power supply for this project) plug the Speaker Cable into your computer or whatever device you are using to play music with and turn on some sort of music.

Open the serial monitor from the Arduino window on your computer and you should see values displayed. If for some reason you are getting zeros, or very low values try changing to a different song with a heavier beat and if that does not change the values you are seeing check all of your connections.

<p>I referred to your instructable to make my VU Meter. I used the following code on an Arduino Uno (i do not own the code, was taken off the internet). The only problem i am facing is that when i plug in my jack into my computer I only get the output on my VU Meter, but i want the sound as well. Is there any solution to this?</p><p>And i also wanted to know what kind of mic will i need to get an analog signal? (except electret)</p><p>CODE:</p><p>// Led VU Meter Example</p><p>// Version 1.0</p><p>// Written by James Newbould</p><p>int led[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // Assign the pins for the leds</p><p>int leftChannel = 0; // left channel input</p><p>int left, i;</p><p>void setup()</p><p>{</p><p>for (i = 0; i &lt; 10; i++) // Tell the arduino that the leds are digital outputs</p><p> pinMode(led[i], OUTPUT);</p><p>// Serial.begin(9600); // Uncomment to enable troubleshooting over serial.</p><p>}</p><p>void loop()</p><p>{</p><p>left = analogRead(leftChannel); // read the left channel</p><p>// Serial.println(left); // uncomment to check the raw input.</p><p>left = left / 50; // adjusts the sensitivity </p><p>// Serial.println(left); // uncomment to check the modified input. </p><p>// left = 1500; // uncomment to test all leds light.</p><p>// left = 0; // uncomment to check the leds are not lit when the input is 0.</p><p> if (left == 0) // if the volume is 0 then turn off all leds</p><p> {</p><p> for(i = 0; i &lt; 10; i++)</p><p> {</p><p> digitalWrite(led[i], LOW);</p><p> }</p><p> }</p><p> else</p><p> {</p><p> for (i = 0; i &lt; left; i++) // turn on the leds up to the volume level</p><p> {</p><p> digitalWrite(led[i], HIGH);</p><p> }</p><p> for(i = i; i &lt; 10; i++) // turn off the leds above the voltage level</p><p> {</p><p> digitalWrite(led[i], LOW);</p><p> }</p><p> }</p><p>}</p>
<p>Could this be done with out having it plugged into a computer? Could it be independently powered, Like through the uno's power port, and still work?</p>
Thanx for the post <br>I am new to arduino e really useful for me <br> <br>Regards <br>www.mzubair.com
Your code is ok, but way to long.<br> <br> int sound[4];<br> int soundav;<br> const int inputPIN =8; //audio input pin, you have to amplify your output to max 5V<br> const int firstLED= 34; //first output pin for the leds<br> const int lastLED = 53; //last output pin for the leds<br> int leds;<br> int x;<br> int y;<br> <br> void setup ()<br> {<br> pinMode (inputPIN, INPUT); // put input pin in input state<br> for (int a=firstLED; a &lt;=lastLED; a++){ // loop through all the outputpins and put them in output state<br> pinMode(a, OUTPUT);<br> }<br> leds = (firstLED + lastLED) +1; //count how many leds you have connected + add 1 for all leds off<br> }<br> <br> void loop ()<br> {<br> for (int num=0; num &lt; 4; num++) {<br> sound[num]= analogRead (inputPIN);<br> if(num==3) {<br> soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4; // average sound levels<br> x = map(soundav, 1, 255, 0,leds); // map the sound values from 0 to 20 because we have 21 levels. OFF &amp; 20 leds.<br> y = firstLED + x; //get the correct led pin number where the led state changes<br> for (int b= firstLED; b &lt; y; b++) { //loops through all the leds from firstLED to the level of the sound<br> digitalWrite(b,HIGH);<br> }<br> for (int c = y; c &lt;= lastLED ; c++) { //loops through all the leds from lastLED to the level of the sound<br> digitalWrite(c,LOW);<br> }<br> }<br> }<br> }<br> <br> This should do the trick in about 35 lines of code.<br> <br> You can use this example for a normal arduino. You only have to change the inputPIN, firstLED and lastLED. And you have to connect all your LED in sequence.<br> <br>
Oh sweet Jebus! I was going nuts 'til I used your code. Thanks!
No problem, I'm glad it worked, because I never tried or used it.
Hi Cinez, great code but it's wrong in a few places and thus doesn't work as it is.<br>Since it's otherwise really good and elegant, I prefer to post just the tiny corrections so you can update it and keep the credit :)<br><br>leds = (firstLED + lastLED) +1; // wrong<br>leds = (lastLED - firstLED) +2; // right<br>You did a sum on the LEDs inputs, when it should be substracted. And you should add &quot;2&quot; instead of &quot;1&quot;, or you'll be missing the last LED, since 54-35 = 19 and not 20. We should add 1 for that LED and another 1 for the ALL OFF as you already pointed out.<br><br>You should also change &quot;PrintSerial&quot; to &quot;Print.serial&quot;.<br><br>And then it'll be working.<br><br>Best wishes<br>
I tried your code but it dosn't work, when i play music the LEDS are always on and when i don't play music the LEDS are still always on<br><br>HELP ME!!!
There is probably something wrong with your input: Try to write a sketch that outputs the soundlevels to the serial console. Use Serial print to debug your sketch. you can see the values in the<br> <br> int sound[4];<br> int soundav;<br> const int inputPIN = 8; //audio input pin, you have to amplify your output to max 5V<br> const int firstLED= 34; //first output pin for the leds<br> const int lastLED = 53; //last output pin for the leds<br> int leds;<br> int x;<br> int y;<br> <br> void setup () {<br> &nbsp; &nbsp; &nbsp;pinMode (inputPIN, INPUT); // put input pin in input state<br> &nbsp; &nbsp; &nbsp;leds = (firstLED + lastLED) +1;<br> &nbsp; &nbsp; &nbsp;Serial.begin(9600);<br> }<br> <br> void loop () {<br> &nbsp; &nbsp; &nbsp;SerialPrint(&quot;soundlevels:&quot;);<br> &nbsp; &nbsp; &nbsp;for (int num=0; num &lt; 4; num++) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sound[num]= analogRead (inputPIN);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SerialPrint(sound[num]);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SerialPrint(&quot; &quot;)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(num==3) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SerialPrint(&quot; Average soundlevel: &quot;);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SerialPrint(soundav); // Print average sound levels in console<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = map(soundav, 1, 255, 0,leds);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SerialPrint(&quot; Mapped soundlevels: &quot;)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SerialPrintln(x); delay(1000); // add delay to prevent to much data been send over Serial connection<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp; &nbsp;}<br> }<br> <br> I did not test the code. But you should get different value outputs when making noise. If not check your circuit if everything is connected the way it should.<br> <br> Ask wunderschonen how he did it.
thank you i got it to work now, it turned out to be my input plug, also can you tell me how to adjust the sensitivity because my ipod has to be on full volume for it to work and then the headphones might as well be used as desk speakers not headphones. thanks
You can very easily adjust the sensitivity of the input.<br>Change the 255 on this line to a lower number.<br>x = map(soundav, 1, 255, 0,leds);<br><br>If you want to change the sensitivity on the fly with a trimpot.<br>Use this http://arduino.cc/en/Tutorial/AnalogInput <br>To change the 255 value on x = map(soundav, 1, 255, 0,leds);.<br><br>sensorValue = analogRead(sensorPin);<br>x = map(soundav, 1, sensorValue, 0,leds);
how can i add a sound shield so i can have one line in and then have the leds flash and have it output sound to a stereo?
Volume is a logarithmic function of amplitude - how does this code sort that out ?
Great project! take a look my similar project <br><br>http://candelectronica.blogspot.com/2011/12/led-vu-meter-en-un-hcs08-freescale.html<br>
hey ,<br><br>thanks for the instructable<br><br>i can't seem to find the code you speak of, is it online? where can i find it..<br>perhaps it is in front of my nose..but where..scratches head.<br><br>thanks<br><br>stephen
~its on the last page
Thanks a mil<br><br>I have got the vu meter up and running thanks!!!!.. just one question<br><br>when i used a normal mp3 the response is great ..but when i use a microphone that is feeding just ambience streets sounds into the system i get very little response.. the mic works fine i wonder how i can calibrate the vu meter to respond to that kind of sound input? any ideas?<br><br>even if i record a short street ambinance mp3 and then play it into the system...turn it up full i still get practically no response?? <br><br>much appreciated!<br><br>kind regards<br><br>stephen
You would need a small amplifyer circuit for the microphone, such as this one https://www.instructables.com/id/Altoids-Amp/ <br> <br>Basicly you are using the circuitry from the tape player to amplify the microphone, if you need any help email/inbox me, id be glad to help :)
I keep getting a .tmp file. Is there another way to download this code other than right-clicking? Sorry, total noob here.
what is the operating voltage i should use for the LEDs?
could you do the same with an arduino duemilanove? and how???
it looks to me just change the pin numbers and go with only one segment or get two arduinos and have one displaying right signal and the other displaying left signal

About This Instructable

50,616views

49favorites

License:

More by dmallen:iBeat Tee VU Meter Light Up Cycling Jersey 
Add instructable to: