Using the Arduino to control 3 modes of spectrum analysis technique with the MSGEQ7.
March 17, 2020
30843 views
5 respects
Devices and components
Arduino Mega 2560 Rev3
LED (generic)
MSGEQ7 Spectrum Analyzer IC
Perma-Proto Half-Size Breadboard
3.5 audio jack
Materials and tools
Wire stripper and cutter, capacity wires 18-10 AWG / 0.75-4 mm²
Software and tools
Arduino IDE
Project description
Introduction:
Goals :
LEDs are connected to PWM digital pins to respond to frequency bands
LEDs are connected to digital pins to respond to frequency bands
The pumps are connected to the Arduino Mega via motor drivers and respond to frequency bands
Theory:
Procedures:
Operating modes:
const
int
LED_pins[7] =
{4,5,6,7,8,9,10};
#define msg7RESET 3
#define msg7Strobe 2
#define msg7DCout 0
const int LEDpins[7] = {4,5,6,7,8,9,10};
void setup()
{
for (int x=0; x<7; x++)
{
pinMode(LEDpins[x], OUTPUT);
}
pinMode(msg7RESET, OUTPUT);
pinMode(msg7Strobe, OUTPUT);
}
void
{
digitalWrite(msg7RESET, HIGH);
delay(5);
digitalWrite(msg7RESET, LOW);
for (int x = 0 ; x < 7 ; x++)
{
digitalWrite(msg7Strobe, LOW);
delayMicroseconds(35);
int spectrumRead = analogRead(msg7DCout);
int PWMvalue = map(spectrumRead, 0, 1024, 0, 255);
if (PWMvalue < 50)
PWMvalue = PWMvalue / 2;
analogWrite(LEDpins[x], PWMvalue);
digitalWrite(msg7Strobe, HIGH);
}
}
const
int
LED_pins[7] =
{40,42,44,46,48,50,52};
#define msg7RESET 3
#define msg7Strobe 2
#define msg7DCout 0
const int LEDpins[7] = {40,42,44,46,48,50,52};
void setup()
{
for (int x=0; x<7; x++)
{
pinMode(LEDpins[x], OUTPUT);
}
pinMode(msg7RESET, OUTPUT);
pinMode(msg7Strobe, OUTPUT);
}
void
{
digitalWrite(msg7RESET, HIGH);
delay(5);
digitalWrite(msg7RESET, LOW);
for (int x = 0 ; x < 7 ; x++)
{
digitalWrite(msg7Strobe, LOW);
delayMicroseconds(35);
int spectrumRead = analogRead(msg7DCout);
int PWMvalue = map(spectrumRead, 0, 1024, 0, 255);
if (PWMvalue < 50)
PWMvalue = PWMvalue / 2;
analogWrite(LEDpins[x], PWMvalue);
digitalWrite(msg7Strobe, HIGH);
}
}
#define msg7RESET 3
#define msg7Strobe 2
#define msg7DCout 0
const int LEDpins[7] = {40,42,44,46,48,50,52};
const int Pumppins[7] = {4,5,6,7,8,9,10};
void setup()
{
for (int x=0; x<7; x++)
{
pinMode(LEDpins[x], OUTPUT);
}
pinMode(msg7RESET, OUTPUT);
pinMode(msg7Strobe, OUTPUT);
}
void
{
digitalWrite(msg7RESET, HIGH);
delay(5);
digitalWrite(msg7RESET, LOW);
for (int x = 0 ; x < 7 ; x++)
{
digitalWrite(msg7Strobe, LOW);
delayMicroseconds(35);
int spectrumRead = analogRead(msg7DCout*1.45);
if (spectrumRead >= 1023)
{
spectrumRead = 1023;
}
int PWMvalue = map(spectrumRead, 0, 1024, 50, 255);
if (PWMvalue < 75)
PWMvalue = PWMvalue / 2;
analogWrite(Pumppins[x], PWMvalue);
analogWrite(LEDpins[x], PWMvalue);
digitalWrite(msg7Strobe, HIGH);
}
}
Raw source code
This code is raw code used to test the functionality of the MSGEQ7 IC
1#define msg7RESET 3
2#define msg7Strobe 2
3#define msg7DCout 0
4
5const int LEDpins[7] = {4,5,6,7,8,9,10};
6
7void setup() {
8
9for (int x=0; x<7; x++)
10{
11pinMode(LEDpins[x], OUTPUT);
12}
13pinMode(msg7RESET, OUTPUT);
14pinMode(msg7Strobe, OUTPUT);
15}
16
17void loop()
18{
19digitalWrite(msg7RESET, HIGH);
20delay(5);
21digitalWrite(msg7RESET, LOW);
22
23for (int x = 0; x < 7; x++)
24{
25digitalWrite(msg7Strobe, LOW);
26delayMicroseconds(35);
27int spectrumRead = analogRead(msg7DCout);
28
29int PWMvalue = map(spectrumRead, 0, 1024, 0, 255);
30if (PWMvalue < 50)
31PWMvalue = PWMvalue / 2;
32analogWrite(LEDpins[x], PWMvalue);
33digitalWrite(msg7Strobe, HIGH);
34}
35}
36
Raw source code
This code is raw code used to test the functionality of the MSGEQ7 IC
1#define msg7RESET 3
2#define msg7Strobe 2
3#define msg7DCout 0
4
5const
6 int LEDpins[7] = {4,5,6,7,8,9,10};
7
8void setup() {
9
10for (int x=0; x<7;
11 x++)
12{
13pinMode(LEDpins[x], OUTPUT);
14}
15pinMode(msg7RESET, OUTPUT);
16pinMode(msg7Strobe,
17 OUTPUT);
18}
19
20void loop()
21{
22digitalWrite(msg7RESET, HIGH);
23delay(5);
24digitalWrite(msg7RESET,
25 LOW);
26
27for (int x = 0; x < 7; x++)
28{
29digitalWrite(msg7Strobe, LOW);
30delayMicroseconds(35);
31int
32 spectrumRead = analogRead(msg7DCout);
33
34int PWMvalue = map(spectrumRead, 0,
35 1024, 0, 255);
36if (PWMvalue < 50)
37PWMvalue = PWMvalue / 2;
38analogWrite(LEDpins[x],
39 PWMvalue);
40digitalWrite(msg7Strobe, HIGH);
41}
42}
43
Downloadable files
LED as PWM outputs
In this regard, we can get the outputs as PWM digital signals. LEDs dim and glow depending on the power of the input frequencies.
LED as PWM outputs
Pumps as digital outputs
In this regard, we can get the output in the form of digital signals. The pumps operate and the LEDs flash depending on the power of the input frequencies.
Pumps as digital outputs
Pumps as digital outputs
In this regard, we can get the output in the form of digital signals. The pumps operate and the LEDs flash depending on the power of the input frequencies.
Pumps as digital outputs
LEDs as digital outputs
In this regard, we can get the outputs as digital signals. The LEDs flash depending on the power of the input frequencies.
LEDs as digital outputs
LED as PWM outputs
In this regard, we can get the outputs as PWM digital signals. LEDs dim and glow depending on the power of the input frequencies.
LED as PWM outputs
Documentation
Schematic connection for MSGEQ7
The main connection of the MSGEQ7 before connecting it to the Arduino.
Schematic connection for MSGEQ7
Schematic connection for MSGEQ7
The main connection of the MSGEQ7 before connecting it to the Arduino.
Schematic connection for MSGEQ7
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.