|
|
Arduino Nano R3 |
x 1 | |
|
|
GP1287 VFD Display |
x 1 | |
|
|
Potentiometer, 10 kohm |
x 1 | |
|
|
Resistor 10k ohm |
x 2 | |
|
|
Capacitor 10 µF |
x 1 | |
|
|
5V 2.5A Switching Power Supply |
x 1 |
|
Soldering Iron Kit |
|
|
arduino IDEArduino
|
Arduino FFT Spectrum analyzer on VFD display GP1287
An audio spectrum analyzer is a device that visualizes the frequency content of an audio signal. It represents the distribution of frequencies in a graphical form, typically displaying amplitude or power on the y-axis and frequency on the x-axis. This tool is commonly used in audio engineering, music production, and sound analysis for various purposes.
This time I will describe how to make an audio FFT spectrum analyzer on a 256x50 pixel VFD display.

These types of displays emit very bright light with high contrast and clear visibility from wide angles, and have a wonderful retro look.
The device is very simple to build and has only a few components:
- Arduino nano microcontroller
- GP1287 VFD display with resolution of 256x50 pixels
- stereo potentiometer
- two capacitors
- two resistors
- and Button

Thanks to the two libraries used (U8G2 and fix_fft), the code is very simple and can be easily modified. The audio input to the Arduino is on A0, with bias at the mid point by 10K to Ground and 10K to +5V. At the input we can also put a potentiometer to control the amplitude of the input signal.
First, let's look at the case when we bring a signal with a certain frequency and shape to the input. For this purpose, I will use the signal generator that is part of my oscilloscope.

The spectrogram clearly shows the fundamental signal, as well as its harmonics. I will test it with square and sine wave. As we change the frequency of the oscillator, so does the fundamental of the analyzer display. Here we can see that the frequency range of this instrument is from 0Hz to 4.5 KHz, where most of the music signals are found. However, the purpose of this device is not to perform any precise audio analyzes and measurements, but primarily has a visual function.
The following image shows how the device works in conditions when we bring a complex audio signal to the input.

Otherwise, the device has two modes of operation that can be changed with the push of a button, in one mode the bars are next to each other, and in the other there is a certain distance between them.

Finally, the entire assembly is housed in a suitable box. This is not a professional tool because it has relatively low resolution and frequency range, but can serve as a great educational tool and visualizer for some audio project.
#include "U8g2lib.h"
#include "fix_fft.h"
#include <SPI.h>
int buttonPin = 2;
int oldButtonVal = 0;
// u8g2 set up, bar, line position L & R
#define LINEY 40
#define LINEXL 0
#define LINEXR 256
#define SAMPLES 128
#define AUDIO A0
U8G2_GP1287AI_256X50_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8GLIB_ST7920_128X64_1X lcd(EN, RW, CS); // serial use, PSB = GND
char im[SAMPLES];
char data[SAMPLES];
int barht[SAMPLES];
int nPatterns = 2;
int lightPattern = 1;
void setup()
{
u8g2.begin(); // inti u8g2
u8g2.setContrast(25);
pinMode(2, INPUT_PULLUP);
}
void loop()
{
static int i, j;
int val;
// get audio data
for(i = 0; i < SAMPLES; i++)
{
val = analogRead(AUDIO)* 50; // 0-1023
data[i] = (char)(val/4 - 128); // store as char
im[i] = 0; // init all as 0
}
// run FFT
fix_fft(data, im, 7, 0);
// extract absolute value of data only, for 64 results
for(i = 0; i < SAMPLES/2; i++)
{
barht[i] = (int)sqrt(data[i] * data[i] + im[i] * im[i]);
}
for(i = 0, j = 0; i < SAMPLES/2; i++, j += 2)
{
barht[i] = barht[j] + barht[j + 1];
}
// u8g2 barchart
barchart(SAMPLES/4, barht); // plot SAMPLES / 4 = 32 as barchart gen cannot handle 128 bars
}
// plot line and bar at position and height
void barchart(int n, int bh[])
{
int i, s, w; // bars, spacing and width
s = (LINEXR - LINEXL) / n;
int buttonVal = digitalRead(buttonPin);
if (buttonVal == LOW && oldButtonVal == HIGH) {// button has just been pressed
lightPattern = lightPattern + 1;
}
if (lightPattern > nPatterns) lightPattern = 1;
oldButtonVal = buttonVal;
switch(lightPattern) {
case 1:
w = s / 2;
break;
case 2:
w = s / 1;
}
u8g2.firstPage();
do
{
u8g2.setFont(u8g2_font_6x12_tf);
u8g2.drawStr(80, 7, "FFT Audio Spectrum");
u8g2.drawLine(LINEXL, LINEY, LINEXR, LINEY);
u8g2.drawStr(0, LINEY + 10, "0");
u8g2.drawStr(50, LINEY + 10, "1k");
u8g2.drawStr(110, LINEY + 10, "2k");
u8g2.drawStr(164, LINEY + 10, "3k");
u8g2.drawStr(220, LINEY + 10, "4k");
u8g2.drawStr(240, LINEY + 10, "Hz");
for(i = 0; i < n; i++)
{
u8g2.drawBox(LINEXL + s * i, LINEY - bh[i], w, bh[i] + 1); // u8glib doesn't accept box height of 0
}
}while(u8g2.nextPage());
}
Arduino FFT Spectrum analyzer on VFD display GP1287
- Comments(0)
- Likes(2)
-
Jorge Tavares
Feb 24,2025
-
M AudioModule
Feb 20,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Mirko Pavleski
-
Arduino 3D Printed self Balancing Cube
Self-balancing devices are electronic devices that use sensors and motors to keep themselves balanc...
-
Build simple Retro Style VFO (Variable frequency oscillator) with Crowoanel 1.28 inch Round Display
Today I received a shipment with a Small round LCD display from Elecrow. The device is packed in tw...
-
Human vs Robot – Rock Paper Scissors with MyCobot 280 M5Stack
Today I received a package containing the few Elephant Robotics products. The shipment is well pack...
-
How to Build a Simple Audio Spectrum Analyzer with Adjustable Settings
An audio spectrum analyzer is an electronic device or software tool that measures and visually disp...
-
How to Make a Digital Clock on a Vintage B&W TV using Arduino
These days I accidentally came across this small retro Black and White TV with a built-in Radio, so ...
-
Build a $10 Function Generator with Frequency Meter for Your Lab
A function generator is a piece of electronic test equipment used to generate various types of elec...
-
From Unboxing to Coding - Radar Clock on Elecrow’s 2.1 HMI Display
Today I received a shipment with a large round LCD display from Elecrow. The device is packed in two...
-
Making a Retro Analog NTP Clock with Unihiker K10 - Arduino IDE Tutorial
Some time ago I presented you a way to use standard Arduino libraries on the Unihiker k10 developme...
-
Build a Cheap & Easy HF Preselector - Antenna Tuner
HF antenna preselector is an electronic device connected between an HF radio antenna, and a radio r...
-
DIY Static Charge Monitor - Electrostatic Field Detector (Arduino & TL071)
A Static Charge Monitor also known as a Static Field Meter or Electrostatic Voltmeter is a device u...
-
XHDATA D-219 Radio Short Review with complete disassembly
Some time ago I received an offer from XHDATA to be one of the first test users of their new radio m...
-
How to make Simplest ever Oscilloscope Clock
An oscilloscope clock is a unique and creative way to display the time using an oscilloscope, which...
-
DIY Digital Barograph with BME280 and ESP32 - 24 Hour Pressure Trends
A barograph is a self-recording barometer that continuously measures and records atmospheric pressu...
-
Build a Raspberry Pi Pico SDR Radio with Waterfall Display
Software-defined radio (SDR) is a radio communication system where components that have traditional...
-
DIY Magnet Polarity Detector - How to Identify Poles with a Hall Sensor from a PC Fan
Recently, while working on a project, I needed to determine the polarity of several permanent magne...
-
Light Meter Project - Making Dfrobot Unihiker K10 Work with Standard Arduino Libraries
The other day I received a shipment with a UNIHIKER K10 development board from DFRobot, which I rec...
-
DIY Simple Arduino Whack-a-Mole Game
A "Whack-a-Mole" game is a classic arcade-style game where moles pop up randomly from holes, and th...
-
Wireless Power Transmission, Long-Distance and High-Efficiency with Class-E Tesla Coil
Wireless energy transfer also known as wireless power transmission is a method of getting useful el...
-
-
AEL-2011 Power Supply Module
322 0 1 -
AEL-2011 50W Power Amplifier
297 0 1 -
-
-
Custom Mechanical Keyboard
565 0 0 -
Tester for Touch Screen Digitizer without using microcontroller
230 2 2 -
Audio reactive glow LED wristband/bracelet with NFC / RFID-Tags
238 0 1 -
-
-







