Mirko Pavleski
Published © GPL3+

Retro Analog style VU meter on VFD display

How to make a VU Meter that uses a VFD (vacuum fluorescent display) instead of analog instruments. VFD Display type is GP1287.

BeginnerFull instructions provided2 hours1,235
Retro Analog style VU meter on VFD display

Things used in this project

Hardware components

GP1287 VFD Display
×1
Arduino Nano R3
Arduino Nano R3
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×2
Resistor 10k ohm
Resistor 10k ohm
×2
Capacitor 10 µF
Capacitor 10 µF
×2
5V 2.5A Switching Power Supply
Digilent 5V 2.5A Switching Power Supply
×1

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

Schematic

...

Code

Arduino code

Arduino
...
#include <U8g2lib.h>
#include <SPI.h>

#define GAIN      100
#define STEP      8
#define LOW_SOUND 50
#define MAX_SOUND 600

 
U8G2_GP1287AI_256X50_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); 

  int strela=-36;
  int hMeter = 64;                      
  int vMeter = 85;                      
  int rMeter = 77;
  int ur,urr,x;

  int strelax =-36;
  int hMeterx = 194;                      
  int vMeterx = 85;                      
  int rMeterx = 77;
  int urx,urrx,xx;
 
void setup(void) {
  u8g2.begin(); 
  u8g2.setContrast(25); 
  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_4x6_tf);
  analogReference(INTERNAL);  // если очень маленький уровень сигнала
  pinMode(A2,INPUT);
  pinMode(A0,INPUT);
}

void loop (){
 
  strela = map(log(analogRead(A2))*GAIN, LOW_SOUND,MAX_SOUND, -36,36);
  strela = constrain(strela, -36, 36);
  urr = strela;if(urr<ur){ur=ur-STEP;}else{ur = strela;}  


  strelax = map(log(analogRead(A0))*GAIN, LOW_SOUND,MAX_SOUND, -36,36);
  strelax = constrain(strelax, -36, 36);
  urrx = strelax;if(urrx<urx){urx=urx-STEP;}else{urx = strelax;}  


  u8g2.firstPage();
  do { 
  u8g2.drawFrame(0,0,256,50);  
  u8g2.drawRFrame(130,2,124,46,3); 
  u8g2.drawRFrame(2,2,127,46,3);
  u8g2.drawLine(20, 15, 70, 15);// line 1
  u8g2.drawLine(150, 15, 200, 15);
  u8g2.drawLine(73, 15, 108, 15);
  u8g2.drawLine(203, 15, 238, 15);
  u8g2.drawLine(73, 14, 108, 14);// line 2
  u8g2.drawLine(203, 14, 238, 14);
  u8g2.drawLine(15, 17, 70, 17);// line3 
  u8g2.drawLine(145, 17, 200, 17); 

  byte b1_2[10]{20,57,42,33,64,91,50,70,77,104};
  byte c1_2[10]{12,14,14,12,14,12,12,12,12,12};
  for(int i=0;i<10;i++){u8g2.drawLine(b1_2[i], 15, b1_2[i], c1_2[i]);} 
  byte b3[5]{15,29,43,57,70};
  for(int i=0;i<5;i++){u8g2.drawLine(b3[i], 17, b3[i], 20);}


  byte b1x_2[10]{150,187,172,163,194,221,180,200,207,234};
  byte c1x_2[10]{12,14,14,12,14,12,12,12,12,12};
  for(int i=0;i<10;i++){u8g2.drawLine(b1x_2[i], 15, b1x_2[i], c1x_2[i]);} 
  byte b3x[5]{145,159,173,187,200};
  for(int i=0;i<5;i++){u8g2.drawLine(b3x[i], 17, b3x[i], 20);}
  

  u8g2.setCursor(17, 10); u8g2.print(F("20 10   3    0 1"));
  u8g2.setCursor(147, 10); u8g2.print(F("20 10   3    0 1"));
  u8g2.setCursor(14, 28); u8g2.print(F("0  25"));
  u8g2.setCursor(144, 28); u8g2.print(F("0  25"));
  u8g2.setCursor(40, 28);  u8g2.print(F("50"));
  u8g2.setCursor(170, 28);  u8g2.print(F("50"));
  u8g2.setCursor(55, 28);u8g2.print(F("75"));
  u8g2.setCursor(185, 28);u8g2.print(F("75"));
  u8g2.setCursor(68, 28);u8g2.print(F("100"));
  u8g2.setCursor(198, 28);u8g2.print(F("100"));
  u8g2.setCursor(90, 10);u8g2.print(F("2"));
  u8g2.setCursor(220, 10);u8g2.print(F("2"));
  u8g2.setCursor(103, 10);u8g2.print(F("3"));
  u8g2.setCursor(233, 10);u8g2.print(F("3"));
  
  u8g2.setCursor(14, 40); u8g2.print(F("-"));
  u8g2.setCursor(104, 40);u8g2.print(F("+"));
  u8g2.setCursor(44, 40);u8g2.print(F("VU meter"));
 
  u8g2.setCursor(90, 40);u8g2.print(F("L"));
  u8g2.drawFrame(88,33,7,9);
  
  u8g2.setCursor(144, 40); u8g2.print(F("-"));
  u8g2.setCursor(234, 40);u8g2.print(F("+"));
  u8g2.setCursor(174, 40);u8g2.print(F("VU meter"));

  u8g2.setCursor(220, 40);u8g2.print(F("R"));
  u8g2.drawFrame(218,33,7,9);

  int a1 = (hMeter + (sin(ur / 57.296) * rMeter)); // meter needle horizontal coordinate
  int a2 = (vMeter - (cos(ur / 57.296) * rMeter)); // meter needle vertical coordinate
  u8g2.drawLine(a1, a2, hMeter, vMeter);
 // u8g2.drawLine(a1-1, a2-1, hMeter-1, vMeter+1);


  int a1x = (hMeterx + (sin(urx / 57.296) * rMeterx)); // meter needle horizontal coordinate
  int a2x = (vMeterx - (cos(urx / 57.296) * rMeterx)); // meter needle vertical coordinate
  u8g2.drawLine(a1x, a2x, hMeterx, vMeterx);
 // u8g2.drawLine(a1x-1, a2x-1, hMeterx-1, vMeterx+1);


  
  } while ( u8g2.nextPage() );  
  
}

Credits

Mirko Pavleski

Mirko Pavleski

127 projects • 1192 followers

Comments