ARDUINO VU METER

hey person reading this.

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
-loading screen(can be removed just for show)
-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 readings[numReadings];      // aantal lezingen
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;
int laad;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);   //lcd configuratie

void setup() {
  
   Serial.begin(9600);
   lcd.begin(16, 2); //bepaling grootte van de lcd
   for (int thisReading = 0; thisReading < numReadings; thisReading++)
   readings[thisReading] = 0;
  
   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++)
    {
      for(laad=0;laad<vul/5;laad++)
      {
        lcd.setCursor(laad, 1); 
        lcd.write(5);
      }
     if(laad<1)
       {
       lcd.setCursor(0, 1); 
        lcd.write(5);
       }
    
     lcd.setCursor(laad+1, 1); 
     lcd.write((vul-vul/5*5)+1);
     for(laad=laad+2;laad<16;laad++)
      {
        lcd.setCursor(laad, 1); 
        lcd.write(9);
      }
    lcd.setCursor(0, 0); 
    lcd.print("loading.........");
    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);
   
    total=analogRead(inputPin);
    if(total > maxi)
    {
      maxi=total;
    }
   
    index++;
   
    if (index >= numReadings)               //Na 5 lezingen gaan we naar 0
    {             
     index = 0;                         
     left=maxi;
     maxi=0;
    }
   
   
    total2=analogRead(inputPin2);
    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);
}

3 People Made This Project!

Recommendations

  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

20 Discussions

None
ThomAce

Tip 4 weeks ago

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!):
- Loading was so slow and unnecessarily complex.
- 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:
- Fixed loading (setup) codes.
- 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.

IMG_20190915_174332.jpg
5 replies
None
siemenwautersThomAce

Reply 4 weeks ago

Hey. Thanks for your reply.
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.

None
ThomAcesiemenwauters

Reply 4 weeks ago

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.

None
siemenwautersThomAce

Reply 4 weeks ago

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

None
ThomAcesiemenwauters

Reply 4 weeks ago


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

None
pinhead1984

6 years ago on Introduction

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.

None
simaopintocorreia

2 months ago

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

None
amion1

3 years ago

I can use a GLCD KS0108? I need help!

None
cybernetsjr

4 years ago

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

2 replies
None
kidos100

5 years ago on Introduction

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.

None
sškvorc1

6 years ago on Step 2

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
None
e.ma.niaksškvorc1

Reply 5 years ago on Introduction

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

None
siemenwauterssškvorc1

Reply 6 years ago on Step 2

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

None
e.ma.niak

5 years ago on Introduction

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.

None
digital25

6 years ago on Introduction

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 ?

I await your response

traduccion en español

Hola Amigo
solo que pueda poner tu diagrama donde pueda conectar la base que son 3 conecciones, donde va las 2 cables al arduino, espero podia ayudar en un dibujo como lo tienes ejemplo la coneccion de lcd con arduino, pero el final de audio stereo donde va coneccion?

Espero su respuesta