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 ads by
Signing UpStep 1Setting up the Breadboard
-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 Step | Download PDFView All Steps | Next Step » |












































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.
HELP ME!!!
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.
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);
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
http://candelectronica.blogspot.com/2011/12/led-vu-meter-en-un-hcs08-freescale.html
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
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
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 :)