ARDUINO VU METER

by siemenwauters in Circuits > Arduino

58725 Views, 66 Favorites, 0 Comments

ARDUINO VU METER

CAM00091[1].jpg
CAM00090[1].jpg
CAM00092[1].jpg
CAM00094[1].jpg
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/

LCD_bb.png
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.


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);
}