3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

VU Meter

VU Meter


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.

 
Remove these adsRemove these ads by Signing Up
 

Step 1Setting up the Breadboard

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.


« Previous StepDownload PDFView All StepsNext Step »
19 comments
Feb 7, 2012. 4:51 PM765mj says:
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?
Feb 10, 2011. 7:31 AMcinezaster says:
Your code is ok, but way to long.

int sound[4];
int soundav;
const int inputPIN =8; //audio input pin, you have to amplify your output to max 5V
const int firstLED= 34; //first output pin for the leds
const int lastLED = 53; //last output pin for the leds
int leds;
int x;
int y;

void setup ()
{
pinMode (inputPIN, INPUT); // put input pin in input state
for (int a=firstLED; a <=lastLED; a++){ // loop through all the outputpins and put them in output state
pinMode(a, OUTPUT);
}
leds = (firstLED + lastLED) +1; //count how many leds you have connected + add 1 for all leds off
}

void loop ()
{
for (int num=0; num < 4; num++) {
sound[num]= analogRead (inputPIN);
if(num==3) {
soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4; // average sound levels
x = map(soundav, 1, 255, 0,leds); // map the sound values from 0 to 20 because we have 21 levels. OFF & 20 leds.
y = firstLED + x; //get the correct led pin number where the led state changes
for (int b= firstLED; b < y; b++) { //loops through all the leds from firstLED to the level of the sound
digitalWrite(b,HIGH);
}
for (int c = y; c <= lastLED ; c++) { //loops through all the leds from lastLED to the level of the sound
digitalWrite(c,LOW);
}
}
}
}

This should do the trick in about 35 lines of code.

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.

Jan 9, 2012. 5:35 PMmacman808 says:
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

HELP ME!!!
Jan 9, 2012. 11:52 PMcinezaster says:
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

int sound[4];
int soundav;
const int inputPIN = 8; //audio input pin, you have to amplify your output to max 5V
const int firstLED= 34; //first output pin for the leds
const int lastLED = 53; //last output pin for the leds
int leds;
int x;
int y;

void setup () {
     pinMode (inputPIN, INPUT); // put input pin in input state
     leds = (firstLED + lastLED) +1;
     Serial.begin(9600);
}

void loop () {
     SerialPrint("soundlevels:");
     for (int num=0; num < 4; num++) {
         sound[num]= analogRead (inputPIN);
         SerialPrint(sound[num]);
         SerialPrint(" ")
         if(num==3) {
              soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4;
              SerialPrint(" Average soundlevel: ");
              SerialPrint(soundav); // Print average sound levels in console
              x = map(soundav, 1, 255, 0,leds);
              SerialPrint(" Mapped soundlevels: ")
              SerialPrintln(x); delay(1000); // add delay to prevent to much data been send over Serial connection
         }
     }
}

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.

Ask wunderschonen how he did it.
Jan 25, 2012. 6:39 PMmacman808 says:
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
Jan 26, 2012. 12:17 AMcinezaster says:
You can very easily adjust the sensitivity of the input.
Change the 255 on this line to a lower number.
x = map(soundav, 1, 255, 0,leds);

If you want to change the sensitivity on the fly with a trimpot.
Use this http://arduino.cc/en/Tutorial/AnalogInput
To change the 255 value on x = map(soundav, 1, 255, 0,leds);.

sensorValue = analogRead(sensorPin);
x = map(soundav, 1, sensorValue, 0,leds);
Jan 4, 2012. 1:03 AMwunderschonen says:
Oh sweet Jebus! I was going nuts 'til I used your code. Thanks!
Jan 4, 2012. 2:31 AMcinezaster says:
No problem, I'm glad it worked, because I never tried or used it.
Feb 23, 2012. 7:52 PMwagedu says:
Hi Cinez, great code but it's wrong in a few places and thus doesn't work as it is.
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 :)

leds = (firstLED + lastLED) +1; // wrong
leds = (lastLED - firstLED) +2; // right
You did a sum on the LEDs inputs, when it should be substracted. And you should add "2" instead of "1", 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.

You should also change "PrintSerial" to "Print.serial".

And then it'll be working.

Best wishes
Jan 4, 2012. 8:44 AMsteveastrouk says:
Volume is a logarithmic function of amplitude - how does this code sort that out ?
Dec 21, 2011. 11:21 AMcandelo says:
Great project! take a look my similar project

http://candelectronica.blogspot.com/2011/12/led-vu-meter-en-un-hcs08-freescale.html
Feb 19, 2011. 9:49 AMrecordmasta001 says:
what is the operating voltage i should use for the LEDs?
Jan 6, 2011. 5:28 AMChimney Toes says:
hey ,

thanks for the instructable

i can't seem to find the code you speak of, is it online? where can i find it..
perhaps it is in front of my nose..but where..scratches head.

thanks

stephen
Jan 12, 2011. 1:42 PMrecordmasta001 says:
~its on the last page
Jan 17, 2011. 8:05 PMt3chnolochic says:
I keep getting a .tmp file. Is there another way to download this code other than right-clicking? Sorry, total noob here.
Jan 13, 2011. 6:09 AMChimney Toes says:
Thanks a mil

I have got the vu meter up and running thanks!!!!.. just one question

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?

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??

much appreciated!

kind regards

stephen
Feb 21, 2011. 2:53 AMrecordmasta001 says:
You would need a small amplifyer circuit for the microphone, such as this one http://www.instructables.com/id/Altoids-Amp/

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 :)
Jan 12, 2011. 2:52 PMrecordmasta001 says:
could you do the same with an arduino duemilanove? and how???
Jan 15, 2011. 9:13 PMhightekrednek2396 says:
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

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
3
Author:dmallen