Maker Pro

Retro look Analog style VU meter on VFD display with Arduino Nano

September 16, 2023 by Mirko Pavleski

This time I will describe how to make a VU Meter that uses a VFD (vacuum fluorescent display) instead of analog instruments. VFD Display type is GP1287.

 A VU meter, also known as a Volume Unit meter, is a device used to display the audio signal level in decibels (dB) in real-time. It is commonly found on audio equipment to help users monitor and control audio levels. The analog VU meter typically consists needle-based indicators that move in response to the audio signal's intensity. 

 This time I will describe how to make such a device that uses a VFD (vacuum fluorescent display) instead of analog instruments. 

 In this particular case, the display is a GP1287 with a resolution of 256 by 50 points, and it can be obtained at a relatively cheap price. In one of my previous videos ( I described how to connect such a display to an ESP32 microcontroller, and this time the display is controlled by Arduino.

The device is extremely simple to build and contains only a few components

  - Arduino Nano Microcontroller

  - GP1287 VFD Display

  - 10K potentiometer,

  - and two capacitors and resistors

 The signal from both audio channels (left and right) is brought to the analog inputs of the Arduino through coupling capacitors. 

 As for the code, I don't have much experience, so feel free to modify and improve it. It is basically based on the U8G2 library, because only this library has support for this kind of VFD display. Also note that when compiling the code you should use the U8G2 library given below. In the first few lines of code we can define the values of Gain, low sound, High Sound, as well as the speed at which the arrow returns to its original position. The sensitivity of the VU meter can be controlled with the potentiometer mounted on the back of the device.

 Finally, a short conclusion. I made the device with the intention of explaining to you how you can connect this type of display to an Arduino microcontroller. In actual operation of the VU meter, the slow response of the hands in relation to the input audio signal can be observed, which is a consequence of the display itself, not the microcontroller or the code. Namely, when testing the code I used a 128х64 LCD display instead of a VFD, and the reaction was almost momentary. Due to the relatively high consumption of the display, it is preferable to power it through the power connector of the display itself, which is shown in the picture.

 The device is installed in a suitable box made of PVC material with a thickness of 5 mm and covered with colored self-adhesive wallpaper

#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) {
  analogReference(INTERNAL);  // если очень маленький уровень сигнала

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

  do { 
  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.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"));

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

Related Content


You May Also Like