Dancing Fountain: Arduino With MSGEQ7 Spectrum Analyzer

Introduction: Dancing Fountain: Arduino With MSGEQ7 Spectrum Analyzer

About: Hello My name is Ahmed Darwish. I’m 39 years old, married and have two wonderful children (Abdulrahman and Emma). I’m an Egyptian electronics and telecommunications engineer. I live and work in State of Kuwait…

The reception of an audio signal and converting it into visual or mechanical reaction is very interesting. In this project we shall use an Arduino Mega to be connected to a spectrum analyzer MSGEQ7 that takes the input audio signal and perform band pass filtering on it to divide it into 7 main frequency bands. The Arduino will then analyze the analogue signal of each frequency band and creates an action.

Step 1: Objectives of the Project

This project will discuss 3 modes of operation:

  1. LEDs are connected to PWM digital pins to react to the frequency bands
  2. LEDs are connected to digital pins to react to the frequency bands
  3. Pumps are connected to the Arduino Mega through Motor drivers and react to the frequency bands

Step 2: Theory

If we talk about the MSGEQ7 Spectrum Analyzer IC we can say that it has internal 7 band pass filters that divides the input audio signal into 7 main bands: 63 Hz, 160 Hz, 400 Hz, 1 kHz, 2.5 kHz, 6.25 kHz and 16 kHz.

The output of each filter is chosen to be the output of the IC by using a multiplexer. That multiplexer has selectors lines controlled by an internal binary counter. So we can say that the counter should count from 0 to 6 (000 to 110 in binary) to allow one band to pass at a time. That makes it clear that the code of the Arduino should be able to reset the counter once it reaches the count 7.

If we have a look on the circuit diagram of the MSGEQ7 we can see that we use RC frequency tuner to control the internal clock of the oscillator. then we use filtering RC elements at the input audio signal port.

Step 3: Procedures

According to the source page (https://www.baldengineer.com/msgeq7-simple-spectrum-analyzer.html) we can see that the source code deals with the outputs as PWM signals that is repetitive. we can change some of the code lines to suite our goals.

We can notice that if we have a stereo jack, we can double the input resistor and capacitor to the second channel. We power the MSGEQ7 from the Arduino VCC (5 volts) and GND. We shall connect the MSGEQ7 to the Arduino board. I prefer to use the Arduino Mega as it has PWM pins suitable for the project. The output of the MSGEQ7 IC is connected to analogue pin A0, the STROBE is connected to pin 2 of the Arduino Mega and the RESET is connected to pin 3.

Step 4: Modes of Operation: 1- LEDs As PWM Digital Outputs

According to the source code, we can connect the output LEDs to pins 4 thru 10

const int LED_pins[7] ={4,5,6,7,8,9,10};

Then we can notice the LEDs dances upon the strength of each frequency band.

Step 5: Modes of Operation: 2- LEDs As Digital Outputs

We can connect the output LEDs to any digital pins.

const int LED_pins[7] ={40,42,44,46,48,50,52};

Then we can notice the LEDs flashes upon the strength of each frequency band.

Step 6: Modes of Operation: 3- Pumps As Digital Outputs

In this last mode we shall connect L298N motor driver module to the outputs of the Arduino. this enables us to control the operation of the pump based on the output of the MSGEQ7 spectrum analyzer.

As known, the motor drivers enable us to control the operation of the connected motors or pumps based on the generated signal from the Arduino without sinking any current from the Arduino, instead they power the motors directly from the connected power source.

If we run the code as raw source, the pumps may not operate properly. That is because the PWM signal is low and will not be suitable for the motor driver to run the motors or pumps and deliver a suitable current. That is why I recommend to increase the PWM value by multiplying the analogue readings from A0 with factor larger than 1.3. This helps the mapping to be suitable for the motor driver. I recommend 1.4 to 1.6. Also we can remap the PWM to be 50 to 255 in order to be sure that the PWM value will be suitable.

We can connect the LEDs together with the outputs for the motor drivers, but the LEDs will not flash in a good visible way like before as the PWM values have been increased. So I suggest to keep them connected to the digital pins 40 thru 52.

Step 7: Contacts

So glad to hear feedbacks from you. Please don't hesitiate to join my channels on:

YouTube: https://www.youtube.com/channel/UCPViv2n5knl22bPtU...

Instagram: @simplydigital010

Twitter: @simply01Digital

Step 8: Codes

Be the First to Share


    • Eggs Challenge

      Eggs Challenge
    • Sculpt & Carve Challenge

      Sculpt & Carve Challenge
    • Remote Control Contest

      Remote Control Contest