Mirko Pavleski
Published © GPL3+

Arduino Bar graph Stereo VU meter on VFD display GP1287

A simple Stereo VU (Volume Unit) meter that represents the intensity of an audio signal using a series of bars. VFD Display type is GP1287.

BeginnerFull instructions provided2 hours636
Arduino Bar graph Stereo VU meter on VFD display GP1287

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
GP1287 VFD display 256x50
×1
2x10k Potentiometer
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×2
Capacitor 10 µF
Capacitor 10 µF
×2
Resistor 4.75k ohm
Resistor 4.75k ohm
×2
Resistor 47.5k ohm
Resistor 47.5k ohm
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Scvhematic diagram

...

Code

Arduino code

C/C++
...
#include <U8g2lib.h>
#include <SPI.h>
 
U8G2_GP1287AI_256X50_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); 

 int  an_izm_r , an_izm_l ; 
 int  ur_l , urr_l , ur_r , urr_r ;


 void setup(void) {
  u8g2.begin(); 
  u8g2.setContrast(15); 
  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_7x14B_tf);
  analogReference(INTERNAL); 
  pinMode(A0,INPUT);
  pinMode(A2,INPUT);
 }

void  loop ( )  { 
  an_izm_r  =  analogRead ( A0 ) ; 
  an_izm_l  =  analogRead ( A2 ) ; 
   urr_l  =  an_izm_l ; 
   urr_r  =  an_izm_r ; 
  if ( urr_l < ur_l ) { ur_l = ur_l - 15 ; } else { ur_l  =  an_izm_l ; } 
  if ( urr_r < ur_r ) { ur_r = ur_r - 15 ; } else { ur_r  =  an_izm_r ; } 
 testfillrect ( ) ; 
 }

 void  testfillrect ( void )  { 
   u8g2.firstPage();
  do {
  u8g2.drawFrame(0,0,256,50);  
  u8g2.drawRFrame(2,2,252,46,3);
  u8g2.drawFrame(5,18,170,14);  
  u8g2.setCursor(16, 30); u8g2.print(F("-20"));
  u8g2.setCursor(77, 30); u8g2.print(F("-10"));
  u8g2.setCursor(140, 30); u8g2.print(F("-3"));
  u8g2.setCursor(8, 16); u8g2.print(F("R"));
  //u8g2.drawFrame(5,4,10,14);
  u8g2.setCursor(8, 44); u8g2.print(F("L"));
  //u8g2.drawFrame(5,32,10,14);
  u8g2.drawBox(18,5,4,11);
  u8g2.drawBox(18,34,4,11);
  u8g2.setFontMode(1);
  u8g2.drawBox(175,18,76,14);
  u8g2.setDrawColor(2);
  u8g2.drawStr(182, 30, "0"); 
  u8g2.drawStr(210, 30, "+3 db"); 

   u8g2.setColorIndex(1);
   for ( int  i = 20 ; i <= ur_r ; i += 4 ) { 
   u8g2.drawBox ( i ,  5 ,  2 ,  11 ) ; 
 }
    for ( int  i = 20 ; i <= ur_l ; i += 4 ) { 
  u8g2.drawBox (  i ,  34 ,  2 ,  11  ) ; 
   
   }
    }
    while ( u8g2.nextPage() );
 }
 
   

Credits

Mirko Pavleski

Mirko Pavleski

152 projects • 1295 followers

Comments