# ARDUINO VU METER

50,210

59

20

last week a friend of mine who is not so familiar with arduino and electronics needed a vu meter for his school project. he supplied me with an arduino and an lcd. the rest was up to me. i searched around the internet to find code for it without succes. many people show a vu meter but dont give any tips or code. so i started to write code myself.

this code is not complete. it does doe strange things when you disconnec the audio jack. also when no ignal is found it gives full barrs(which i like)

what is complete is:
-nice looking edges
-signal smoothening
-arduino shield-like connectins(just plug it on and ready)

1 thing i ask from you. i am a youtube partner. i dont get many vieuws but the money i get from it always goes to projects like this. if you just watch the video below and check out my channel for my other video's it would be of great help to me.

thank you for reading this and enjoy the code.

for more projects visit my site : http://iprototype4u.tk/

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1:

first you need to connect the lcd screen. the pinout is like on the picture. the potentiometer is to adjust the contrast of the screen so you get nice clear image.

## Step 2:

this is the code enjoy. the analog inputs used are A2 and A4

//VU meter by theredstonelabz and michiel H don't forget to like and subscribe to support my work. tnx

#include <LiquidCrystal.h>

//speciale caracters
byte p3[8] = {
B11111,
B00000,
B10000,
B10000,
B10000,
B10000,
B00000,
B11111
};

byte p4[8] = {
B11111,
B00000,
B11000,
B11000,
B11000,
B11000,
B00000,
B11111
};

byte p5[8] = {
B11111,
B00000,
B11100,
B11100,
B11100,
B11100,
B00000,
B11111
};

byte p6[8] = {
B11111,
B00000,
B11110,
B11110,
B11110,
B11110,
B00000,
B11111
};

byte p7[8] = {
B11111,
B00000,
B11111,
B11111,
B11111,
B11111,
B00000,
B11111
};

byte L[8] = {
B11111,
B00000,
B11111,
B10000,
B10000,
B10000,
B00000,
B11111
};

byte R[8] = {
B11111,
B00000,
B11111,
B00101,
B00101,
B11010,
B00000,
B11111
};

byte K[8] = {
B11100,
B11110,
B11111,
B11111,
B11111,
B11111,
B11110,
B11100
};

byte LEEG[8] = {
B11111,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111
};

int leftChannel = 0;   // linker kanaal input
int rightChannel = 0;  // rechter kanaal input

int left,left2,right,right2;  //variabelen
const int numReadings = 3;    //5 lezingen voor data

int index = 0;                  // index van de momentele lezing
int total= 0;                   //totaal op nul zetten
int maxi=0;
int index2 = 0;                 // index van de momentele lezing (2)
int total2= 0;                  // hoogste getal in de lezingen
int maxi2=0;
int inputPin = A2;              //ingangspin links
int inputPin2 = A4;             //ingangspin rechts
int volL=0;
int volR=0;
int carL=0;
int carR=0;
int vul;
int vul2;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);   //lcd configuratie

void setup() {

Serial.begin(9600);
lcd.begin(16, 2); //bepaling grootte van de lcd

lcd.createChar(1, p3);
lcd.createChar(2, p4);
lcd.createChar(3, p5);
lcd.createChar(4, p6);
lcd.createChar(5, p7);
lcd.createChar(6, L);
lcd.createChar(7, R);
lcd.createChar(8, K);
lcd.createChar(9, LEEG);

for(vul=0;vul<80;vul++)
{
{
lcd.write(5);
}
{
lcd.setCursor(0, 1);
lcd.write(5);
}

lcd.write((vul-vul/5*5)+1);
{
lcd.write(9);
}
lcd.setCursor(0, 0);
delay(50);
}
lcd.clear();
delay(500);

}

void loop()

{
lcd.setCursor(0, 0);       //L en R worden op het scherm gezet
lcd.write(6);
lcd.setCursor(0, 1);
lcd.write(7);
lcd.setCursor(15, 0);       //kapjes worden op het scherm gezet
lcd.write(8);
lcd.setCursor(15, 1);
lcd.write(8);

if(total > maxi)
{
maxi=total;
}

index++;

if (index >= numReadings)               //Na 5 lezingen gaan we naar 0
{
index = 0;
left=maxi;
maxi=0;
}

if(total2 > maxi2)
{
maxi2=total2;
}

index2++;

if (index2 >= numReadings)               //Na 5 lezingen gaan we naar 0
{
index2 = 0;
right=maxi2;
maxi2=0;
}

volR=right/3;

if(volR>14)
{
volR=14;
}
for(vul = 0 ; vul < volR ; vul++)
{
lcd.setCursor(vul+1, 1);
lcd.write(5);
}

for(vul = volR+1 ; vul < 15 ; vul++)
{
lcd.setCursor(vul, 1);
lcd.write(9);
}

volL=left/3;

if(volL>14)
{
volL=14;
}
for(vul2 = 0 ; vul2 < volL ; vul2++)
{
lcd.setCursor(vul2+1, 0);
lcd.write(5);
}

for(vul2 = volL+1 ; vul2 < 15 ; vul2++)
{
lcd.setCursor(vul2, 0);
lcd.write(9);
}
Serial.println(left);
}

## Recommendations

• ### Internet of Things Class

22,790 Enrolled

## 20 Discussions

Dear Friend,
Your idea was great, and thanks for it. This was my second try with Arduino.
However some improvement is needed in your code as I have seen. The code was hard to read so I rewritten it a little bit. I added some more features as well.

Problems I found with the original code (Without blaming, just the pure facts!):
- Code doubling symtom.
- When no sound presented, almost half of the bar-width was still used because of incorrect calculation of the input audio level.
- The display driving in the way you did caused bad readability of the actual volume level.
- Some codes does absolutely nothing just occupied the space and memory.
- Too many loops used for drawing for no real reason.

What I did:
- Removed some of the non-required variables and codes that are not produced anything valuable.
- Changed the pins for input and LCD driving. (Just for presonal feelings!)
- Changed the way how the bar data is interpreted.
- Changed the way how bar data is written to lcd.
- Added peak detection and drawing.

What could be done more:
- For better visual representation: Calculate the average of every 3 or 6 reads and show only that, but using my routines.

Later on I might make some comparison of the original and fixed one.

5 replies

As you can see this project was made a long time ago so for me this was also thinkering with arduino without any previous coding knowledge. Its nice to see that some years later people still use my instructable and improve the original project. Good job on the upgrades. These are things i learned later on as well but did not have the time to update old projects since i dont need this anymore. Do you have an instructable for yours? If so i can link it in mine to show people the updated version.

Hello Siemenwauters, Thanks for the quick response. IMHO: Old project != bad project. :) I have not publicated yet, but I'll upload it to Arduino forum as soon as my blue LCD will arrive. Of course, I'll refer to your project.

Allright comment the link here later so i can add it to the instructable :) good job !

This is the first, public demonstration video. The 90% of the code is now rewritten, but the original idea and credits are still there. ;)

I'm having difficulties identifying where I could adjust the sensitivity for either channel. I find that it is still producing a reading when there is no sound being inputed from a device.

2 replies

that is indeed a problem i have as well. its becous of signal interference if you touch the jack it wil also start to move. i am just a beginning programmer so i did not know how to solve this. i hope you still enjoy the rest of the working code. maby someone else can solve this.

It is amazing and it works good with my MP4 ,you can make a circuit for LED's ,for look more professional .

I can use a GLCD KS0108? I need help!

Funciono bien, las entradas analogicas son A2 para L y A4 para R muchas gracias, felicidades por el post

2 replies

Not sure about you, but here's how I connect my LCD. http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kits/SFE-SIK-RedBoard-Guide-Version3.0-Online.pdf Look on page 80.

I would really like to do a VU-meter with 20 LED-s controlled by Arduino Duemilanove but I don't know how.Could you help me?

2 replies

Use shift registers, with them u can make that vu meter how long u want. And u need only few pins.

As far as i know a deumi has only 13 digital pins. So only if you work with and gates and a lot of them its not possible to connect 20 separate outputs to a deumi maby get yourself a mega? I think they have over 20 digital ports. The code for your project is verry easy to write. You just have to adapt standard vu code

Hope this helps

THIS.............IS...............AWESOME! And it works on first try. Great job. I'm using 4 row display, thinking abou a spectum analyser done in the same way.

Hello Friend
I can only put your diagram where you can connect the dock are three connections, where the 2 cables going to arduino, I hope I could help you a picture as example the connection of lcd with arduino, but the final stereo audio connection which will ?