Introduction: Arduino Based Mini Audio Spectrum Visualizer

For our last instructable, we built a 3D Stereo Audio Spectrum Visualizer. We are delighted that it attracted quite a bit of interest from the community with suggestions on how we could have built the display differently. Some argued that it is not a true 3D audio spectrum visualizer and we totally agree with them. We should have titled that project more appropriately. If you are interested, you may check out the instructable here.

Following that last project, we have made the stereo audio spectrum visualizer board into a basic DIY kit which is now available at jolliFactory's Tindie store.

This audio spectrum visualizer kit is also suitable for use in our other Arduino based Bi-color LED Matrix Audio Spectrum Visualizer instructable project.

These two audio spectrum visualizer projects use SPI for connections to the more elaborate bi-color LED Matrix and 3D LED Matrix displays for visualization. For this instructable, we will be building yet another audio spectrum visualizer but we will be using a 0.96 inch 128x64 I2C OLED graphic display instead. This is quite a tiny display but that is all we have lying around. You may want to use a larger screen OLED display for your project. This is a much simpler project if you just like to experiment with audio spectrum visualizers and do not want to spend too much time and money on the display.

You may find the 0.96 inch I2C OLED display from Adafruit or as an add-on module with our JF Stereo Audio Spectrum Visualizer DIY kit.

You may view the following YouTube video to see what we are building.

Step 1: Building the Audio Spectrum Visualizer Board

You may wire up the audio spectrum visualizer board using perf-board yourself according to the wiring diagram above. We will not go into detail on how to wire them up here.

For this project, to save time from having to wire up the circuit, we will be using the JF Stereo Audio Spectrum Visualizer kit set available on Tindie. For this project, we assume you have some basic electronics and soldering skills and is familiar with using the Arduino board. The kit set is quite simple to complete. So, we will not be going into the detail on assembling the JF Stereo Audio Spectrum Visualizer board here.You will need to ensure the MSGEQ7 ICs and the Arduino Nano are placed in the correct orientation.

Our audio spectrum visualizer shall be driven by an Arduino Nano. We will basically be using two MSGEQ7 IC chips made by Mixed Signal Integration to separate the audio into bands. The MSGEQ7 IC is a single channel seven band Graphic Equalizer Display Filter. By feeding an audio signal to it, it will filter out seven frequency bands centered around 63Hz, 160Hz, 400Hz, 1,000Hz, 2,500Hz, 6,250Hz, and 16,000Hz. The seven frequencies are peak detected and multiplexed to the output to provide a DC representation of the amplitude of each band. All we need is to read these DC values with the microcontroller analog input and output the spectrum to the OLed display. We need two MSGEQ7 ICs here, one for the left and another for the right audio channel.

Step 2: Wiring Connections

The main objective of this project is for experimentation on audio spectrum visualization. To keep it as simple as possible, we will be using an off-the-shelf mini 0.96 inch I2C OLED graphic display instead of building elaborate displays. This display requires only 2 signal lines and 5V DC for power. See the photos above on how the I2C OLED is connected to the JF Audio Spectrum Visualizer board.

The I2C OLED display is available at Adafruit or as an add-on part if you purchase the JF Stereo Audio Spectrum Visualizer kit which will be made available soon.

We have also connected a momentary push button switch to SW1 on the PCB board which is connected to D8 and GND of the Arduino board. This switch shall be used for selection of different display effects.

Step 3: Programming the Arduino Board

The Arduino board needs to be loaded with the Arduino sketch to drive the Audio Spectrum Visualizer.
Download jolliFactory_I2C_OLED_AudioSpectrumVisualizer.ino

You will need to install the support library for the OLED graphics display which is available for download below.

Download Adafruit SSD1306 Library

You will also need to install the Adafruit GFX library.

Download Adafruit GFX Library

You may need to change the I2C device address in the sketch for it to work with your OLED display. Our OLED display is using I2C address 0x3C by default.

If you are not sure what is your I2C device address, you can download an Arduino I2C scanner sketch to determine the address. Check out I2C Scanner page at Arduino playground for more information.

We have only designed three effects for the audio spectrum visualizer. Let your creative juice flow and enhance the program with more interesting effects.

Step 4: Testing the Audio Spectrum Visualizer

We will not delve into the details on how to test if our audio spectrum visualizer is performing correctly here. You may check out Step 4 in our last instructable here to see how to conduct a similar test.

Step 5: Building the Enclosure

If you are just building this project for experimentation, you may not want to invest time and money to build an enclosure for your visualizer.

However, we have some time on our hand while working on this project and so we decided to build a simple enclosure.

See the photos above for our enclosure. We will however not delve into the details on how we build it here.

Step 6: Let in the Music and ENJOY

Though the OLED graphic display used for this project is small, it is still quite mesmerizing to watch the display dance to the music.

For this project, we have created 3 different display effects for visualizing the audio spectrum. You may create you own unique display effects for your audio spectrum visualizer project. You may also try out using different types and form of displays for audio visualization.

The JF Stereo Audio Spectrum Visualizer kit is also suitable for use in our Arduino based Bi-color LED Matrix Audio Spectrum Visualizer instructables project as well as the 3D Stereo Audio Spectrum Visualizer instructables project. You may check them out if you are interested.


oxrod (author)2017-02-12

Is there a picture of where the push button goes into the PCB board? THis is the only part i'm having trouble figuring out.

jollifactory (author)oxrod2017-02-12

You need to connect your push button switch to the two terminals labelled as SW1 on the PCB which is located just below the USB socket of the Arduino Nano if it is inserted onto the board.

oxrod (author)jollifactory2017-02-13

OK, I should have been a little more clear. Is the SW1 the pair I marked with red dots or the pair I marked with blue?

jollifactory (author)oxrod2017-02-17

Sorry for the late reply. Push button is to be connected to the red dots.

oxrod made it! (author)jollifactory2017-02-19

OK, I finished building the board and it's components. I could not upload the sketch to the Arduino without getting an error like this:

"Height incorrect, please fix Adafruit_SSD1306.h!"

So I added the following line to the sketch:

#define SSD1306_LCDHEIGHT 64

on top of

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");

That allowed me to upload the sketch. But, when I hooked up the music, all I could see on the .96" screen is "LEFT" and "RIGHT." I thought it was not working until I noticed I could see it working when I turned up the volume above 8 on the volume dial. I thought it still looked a bit weird until I used the push button to change the effects. The second effect where the bars grow from the middle of the screen (I added an image below) is not in the middle of my screen, it's at the bottom (example In the same image below.) It appears the graphics are stretched beyond the bottom of my screen and that's why I could not see the bars moving until I turned the volume up real loud. Your effect 2 starts in the middle of the screen and mine starts somewhere below the bottom. Does this have to do with the line of code I added? Any idea why my graphics seem to be stretched?

jollifactory (author)oxrod2017-02-20

You should amend the Adafruit_SSD1306.h file found in your Arduino IDE libraries/Adafruit_SSD1306 folder and not the Arduino sketch itself.

Search for something like the followings in the file and comment out the displays you are not using;

#define SSD1306_128_64
// #define SSD1306_128_32
// #define SSD1306_96_16

oxrod (author)2017-01-18

Hello, I love this project, but I want to make it with a larger OLED display. Id like to use this:

This looks like it would work the I right?

jollifactory (author)oxrod2017-01-27

The display we are using is 5V-ready, so we can connect them directly to the Arduino Nano. You will need a level shifter for the larger OLED display from Adafruit which should be included with the purchase.

The larger display uses driver chip SSD1305 which can communicate in three ways: 8-bit, I2C or SPI. You will need to check out their tutorial on how to convert it for I2C communications which is what we are using for this project.

You will also need to modify our code to use the SSD1305 driver library instead of the SSD1306 driver library we are using.