use msgeq7 and arduino to drive 7 5v relays

hey everyone

i am new to the Arduino world. i am triing to use a MSGEQ7 chip to drive 5v relays so i can hook up christmas lights to musiv on 7 bands. i have looked at some codes and even triies some sketches but not sure if i am getting the right code or all the code is there any one who can help me

I've never used the MSGEQ7, but I understand generally how it works.

Can we see the code you have, or the example code you want to modify?

You should have 7 variables, each representing the level of one frequency band. Then it's just a matter comparing those variables to a reference/threshold variable with an if-statement, and turning-on/off a relay based on the results of the if-statements..

The basic logic would be: if BandOne >= ThresholdOne, RelayOne on, else turn RelayOne off.

If you are using mechanical relays and/or incandescent lamps, you may want a delay of 1/10th of a second or more after turning the relays on/off. Very short pulses won't turn-on a mechanical relay and incandescent bubls take a fraction of a second to warm-up before they glow. I normally use a 100mS (1/10th of a second) delay with solid state relays and incandescent lamps. That's enough time for the lamp to flash-on (maybe to full brightness), but if the lamp is on and I pulse it off for 100mS, the lamp stays mostly-lit and it's not as noticeable. Even with LED lamps, you might want a short delay so that you can actually see the "flicker", or it just might be more pleasing with slower blinking.


As always, I recommend that you start-out simple and "develop" your software. I'd start by "blinking" the relays/lights under software control without any audio input.

Then add the audio input. Maybe send the input variables to the Serial Monitor to see what you are getting.

Make one channel/band blink to the music before adding the other 6.


Once you get the thing basically working, you can make some enhancements. You'll probably get the best results if you adjust your thresholds automatically, depending on the signal levels you are getting (the volume and frequency content).

I usually save an ADC reading once per second in an array and take a 20-second moving-average (take a look at the "Smoothing" Example). Some of my effects use the average as the threshold, some use the peak value in the 20-second array, and some take the halfway-point between the average & peak. For stereo, I have two arrays. For 7 bands, you may want 7 arrays.

i wired up my msgeq7 to my arduino and used the following code from nuewire i even rewired my project it just doesnt seem that the audio signal is getting to the arduino i have reviewed the serial monitor the numbers flash at random even when audio is turned off any suggestions

int analogPin = A0;
int strobePin = 11;
int resetPin = 12;
int spectrumValue[7];

void setup()
{
Serial.begin(9600);
pinMode(analogPin, INPUT);
pinMode (strobePin, OUTPUT);
pinMode (resetPin, OUTPUT);
analogReference (DEFAULT);

digitalWrite (resetPin, LOW);
digitalWrite (strobePin, HIGH);

Serial.println("MSGEQ7 TEST");
}

void loop()
{
digitalWrite (resetPin, HIGH);
digitalWrite (resetPin, LOW);

for (int i = 0; i < 7; i++)
{
digitalWrite (strobePin, LOW);
delayMicroseconds(30);
spectrumValue = analogRead(analogPin);

if (spectrumValue*<10)*

{
* Serial.print("");*
_ Serial.print(spectrumValue*);
}_
_else if (spectrumValue<100)
{
Serial.print("");
Serial.print(spectrumValue);
}
else
{
Serial.print("");
Serial.print(spectrumValue);
}
digitalWrite (strobePin, HIGH);
}
Serial.println();
}*_

Please use code tags.

Read this before posting a programming question

   Serial.print("");

What is this supposed to do, besides waste time. Do you really want to be wasting time when the purpose of the chip is to analyze audio data?

I have changed my code and now the relays are flashing but not to the music , IN FACT THE RELAYS FLASH WITHOUT AUDIO INPUT AT ALL I still think that the audio is not being read correctly. SORRY FOR NOT USING CODE TAGS STILL TRIING TO GET ALL THIS FORUM STUFF FIGURED OUT. THANKS FOR EVERYONES HELP

int analogPin = A0; // MSGEQ7 OUT 3
int strobePin = 11; // MSGEQ7 STROBE 4
int resetPin = 12; // MSGEQ7 RESET 7
int spectrumValue[7];

// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;

// LEDs pins, connected to the PWM pins on the Arduino
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 10;
void setup()
{
Serial.begin(9600);
// Read from MSGEQ7 OUT
pinMode(analogPin, INPUT);
// Write to MSGEQ7 STROBE and RESET
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
pinMode (ledPin1,OUTPUT);
pinMode (ledPin2,OUTPUT);
pinMode (ledPin3,OUTPUT);
pinMode (ledPin4,OUTPUT);
pinMode (ledPin5,OUTPUT);
pinMode (ledPin6,OUTPUT);
pinMode (ledPin7,OUTPUT);

digitalWrite (ledPin1,LOW);
digitalWrite (ledPin2,LOW);
digitalWrite (ledPin3,LOW);
digitalWrite (ledPin4,LOW);
digitalWrite(ledPin5,LOW);
digitalWrite (ledPin6,LOW);
digitalWrite (ledPin7,LOW);

// Set analogPin's reference voltage
analogReference(DEFAULT); // 5V

// Set startup values for pins
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
}

void loop()
{
// Set reset pin low to enable strobe
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);

// Get all 7 spectrum values from the MSGEQ7
for (int i = 0; i < 7; i++)
{

digitalWrite(resetPin,HIGH);
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // Allow output to settle

spectrumValue = analogRead(analogPin);

  • // Constrain any value above 1023 or below filterValue*
    spectrumValue = constrain(spectrumValue*, filterValue, 1023);*

* // Remap the value to a number between 0 and 255*
spectrumValue = map(spectrumValue*, filterValue, 1023, 0, 255);*

* {*

* if (spectrumValue[0])*
* digitalWrite (ledPin1,HIGH);*
* delay (100);*
* digitalWrite (ledPin1,LOW);*
* if (spectrumValue[1])*
* digitalWrite (ledPin2,HIGH);*
* delay (100);*
* digitalWrite (ledPin2,LOW);*
* if (spectrumValue[2])*
* digitalWrite (ledPin3,HIGH);*
* delay (100);*
* digitalWrite (ledPin3,HIGH);*
* if (spectrumValue[3])*
* digitalWrite (ledPin4,HIGH);*
* delay(100);*
* digitalWrite(ledPin4,LOW);*
* if (spectrumValue[4])*
* digitalWrite (ledPin5,HIGH);*
* delay (100);*
* digitalWrite (ledPin5,HIGH);*
* if (spectrumValue[5])*
* digitalWrite (ledPin6,HIGH);*
* delay (100);*
* digitalWrite (ledPin6,LOW);*
* if (spectrumValue[6])*
* digitalWrite(ledPin7,HIGH);*
* delay (100);*
* digitalWrite (ledPin7,LOW);*
* } *

* }*
}

Code tags are the # icon on the editor toolbar.

carlbenishek:
I have changed my code and now the relays are flashing but not to the music , IN FACT THE RELAYS FLASH WITHOUT AUDIO INPUT AT ALL I still think that the audio is not being read correctly. SORRY FOR NOT USING CODE TAGS STILL TRIING TO GET ALL THIS FORUM STUFF FIGURED OUT. THANKS FOR EVERYONES HELP

That's why we ask you to read the "sticky".

How to use this forum

Including the part about not shouting in all caps.

See this:

I think you're missing a whole bunch of {} braces in your "if" statements (as well as the code tags).
Check some of the examples on how to write an "if" statement.

Thanks for the info. I will review the if statements and i am sorry for "yelling" in all caps that is just what i do. and thanks for the code tag info

Thanks for the response here is the code i am currently triing to modify

int analogPin = A1; // MSGEQ7 OUT 3
int strobePin = 11; // MSGEQ7 STROBE 4
int resetPin = 12; // MSGEQ7 RESET 7 
int spectrumValue[7];
 
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
 


// LEDs pins, connected to the PWM pins on the Arduino
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 10;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  
  pinMode (ledPin1,OUTPUT);
  pinMode (ledPin2,OUTPUT);
  pinMode (ledPin3,OUTPUT);
  pinMode (ledPin4,OUTPUT);
  pinMode (ledPin5,OUTPUT);
  pinMode (ledPin6,OUTPUT);
  pinMode (ledPin7,OUTPUT);
  
  digitalWrite (ledPin1,LOW);
  digitalWrite (ledPin2,LOW);
  digitalWrite (ledPin3,LOW);
  digitalWrite (ledPin4,LOW);
  digitalWrite(ledPin5,LOW);
  digitalWrite (ledPin6,LOW);
  digitalWrite (ledPin7,LOW);
  
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
 
  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}
 
void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
  
    digitalWrite(resetPin,HIGH);
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);
 
    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
 
    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
 
  
 
  { 
  
 
   if (spectrumValue[0])
  {
        digitalWrite (ledPin1,HIGH);
         delay (30);
        digitalWrite (ledPin1,LOW);
  }
  
  else if (spectrumValue[1])
  {
        digitalWrite (ledPin2,HIGH);
         delay (30);
        digitalWrite (ledPin2,LOW);
  }
  
  else if (spectrumValue[2])
    {
      digitalWrite (ledPin3,HIGH);
         delay (30);
        digitalWrite (ledPin3,LOW);
    }
     else if (spectrumValue[3])
     {
       digitalWrite (ledPin4,HIGH);
         delay(30);
        digitalWrite(ledPin4,LOW);
     }
     
     else if (spectrumValue[4])
       {
         digitalWrite (ledPin5,HIGH);
         delay (30);
         digitalWrite (ledPin5,LOW);
       }
       
    else if  (spectrumValue[5])
      
      {
      digitalWrite (ledPin6,HIGH);
      delay (30);
      digitalWrite (ledPin6,LOW);
      }
       else if (spectrumValue[6])
     {
      digitalWrite(ledPin7,HIGH);
      delay (30);
      digitalWrite (ledPin7,LOW);
     }  
}   
 
    
   }
}

Hello every one. I am currently working on a project to use my Arduino and MSGEQ7 to read from my MP3 player to run my Christmas lights. Has anyone succesfully accomplished this? my project seems to function but not quit right. when music is applied the relays open and close and when music is off the relays stay open. it just doesnt seem like the music is in sync with the relays

here is my code can anyone help

int analogPin = A1; // MSGEQ7 OUT 3
int strobePin = 11; // MSGEQ7 STROBE 4
int resetPin = 12; // MSGEQ7 RESET 7 
int spectrumValue[7];
 
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
 


// LEDs pins, connected to the PWM pins on the Arduino
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 10;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  
  pinMode (ledPin1,OUTPUT);
  pinMode (ledPin2,OUTPUT);
  pinMode (ledPin3,OUTPUT);
  pinMode (ledPin4,OUTPUT);
  pinMode (ledPin5,OUTPUT);
  pinMode (ledPin6,OUTPUT);
  pinMode (ledPin7,OUTPUT);
  
  digitalWrite (ledPin1,LOW);
  digitalWrite (ledPin2,LOW);
  digitalWrite (ledPin3,LOW);
  digitalWrite (ledPin4,LOW);
  digitalWrite (ledPin5,LOW);
  digitalWrite (ledPin6,LOW);
  digitalWrite (ledPin7,LOW);
  
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
 
  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}
 
void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite (resetPin,HIGH);
  digitalWrite(resetPin, LOW);
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
  
    digitalWrite (resetPin,HIGH);
    digitalWrite(strobePin, LOW);
    delayMicroseconds(10); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);
 
    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);
 
    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);
 
   digitalWrite (strobePin,HIGH); 

  { 
  
 
   if (spectrumValue[0])
  {
        digitalWrite (ledPin1,HIGH);
         delay (30);
        digitalWrite (ledPin1,LOW);
  }
  
  else if (spectrumValue[1])
  {
        digitalWrite (ledPin2,HIGH);
         delay (30);
        digitalWrite (ledPin2,LOW);
  }
  
  else if (spectrumValue[2])
    {
      digitalWrite (ledPin3,HIGH);
         delay (30);
        digitalWrite (ledPin3,LOW);
    }
     else if (spectrumValue[3])
     {
       digitalWrite (ledPin4,HIGH);
         delay(30);
        digitalWrite(ledPin4,LOW);
     }
     
     else if (spectrumValue[4])
       {
         digitalWrite (ledPin5,HIGH);
         delay (30);
         digitalWrite (ledPin5,LOW);
       }
       
    else if  (spectrumValue[5])
      
      {
      digitalWrite (ledPin6,HIGH);
      delay (30);
      digitalWrite (ledPin6,LOW);
      }
       else if (spectrumValue[6])
     {
      digitalWrite(ledPin7,HIGH);
      delay (30);
      digitalWrite (ledPin7,LOW);
     } 
  
}   
 
    
   }
}
// LEDs pins, connected to the PWM pins on the Arduino
int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
int ledPin5 = 8;
int ledPin6 = 9;
int ledPin7 = 10;

An array would be so much simpler.

Where are the relay pins?

   if (spectrumValue[0])
  {

spectrumValue[n] is not a boolean. Why are you treating it as one?

Why haven't you used Tools + Auto Format before
posting code, so that it
doesn't wander all
over the place like
a drunken sailer?

I borrowed parts of this code from individual other codes. The relay pins are actually labeled ledpin. I am pretty new to Arduino so i tried what I thought would work. I borrowed spectrumvalue to read the 7 inputs from msgeq7 and help transfer them dto the ledpin digital outputs. I thought this would work. Is there a simpler way

I borrowed parts of this code from individual other codes.

Do you plan to return them? If not, borrowed is not the correct term.

The relay pins are actually labeled ledpin.

You have a choice. Replace the relays with LEDs and keep the names. Or, change the names to reflect the hardware that you have. Keeping misleading names is not a viable option.

How would you feel if the Verify button opened the Serial Monitor, and the Upload button opened a new sketch, and the Open button uploaded the code? Quite confused, even if there was a pattern that you could learn.

I borrowed spectrumvalue to read the 7 inputs from msgeq7

What values are ending up in spectrumvalue[ 0 ] to spectrumvalue[ 6 ]? You are assuming that the values are 0 or 1, in the way that you use them, when I doubt that that is really the case. From my reading of the code, the values should be between 0 and 255. So, 254 of the values are true, and 1 of the values is false.

Thanks for the advice to change the names of the pins to relay pins. I was assuming that the spectrum values would be the related to the seven bands of the graphic equalizer from the MSGEQ7. You really know what is going on have you tried to do what I am triing and did it work. do you know of anyone who has already created this project. i will reytpe the code and cahnge the names. maybe you will have more advice after i repost code

here is the code i am currently using. When music is applied to MSGEQ7 all seven relays flash but not in sequence to music when no music is applied relays are off can any one help

int analogPin = A1; // MSGEQ7 OUT 3
int strobePin = 11; // MSGEQ7 STROBE 4
int resetPin = 12; // MSGEQ7 RESET 7 
int spectrumValue[7];
 
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
 


// RELAY pins, connected to pins on the Arduino
int relayPin1 = 2;
int relayPin2 = 3;
int relayPin3 = 4;
int relayPin4 = 5;
int relayPin5 = 8;
int relayPin6 = 9;
int relayPin7 = 10;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  
  pinMode (relayPin1,OUTPUT);
  pinMode (relayPin2,OUTPUT);
  pinMode (relayPin3,OUTPUT);
  pinMode (relayPin4,OUTPUT);
  pinMode (relayPin5,OUTPUT);
  pinMode (relayPin6,OUTPUT);
  pinMode (relayPin7,OUTPUT);
  
  digitalWrite (relayPin1,LOW);
  digitalWrite (relayPin2,LOW);
  digitalWrite (relayPin3,LOW);
  digitalWrite (relayPin4,LOW);
  digitalWrite (relayPin5,LOW);
  digitalWrite (relayPin6,LOW);
  digitalWrite (relayPin7,LOW);
  
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
 
  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}
 
void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite (resetPin,HIGH);
  digitalWrite(resetPin, LOW);
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
  
    
    digitalWrite(strobePin, LOW);
    delayMicroseconds(2); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);
 
    digitalWrite (strobePin,HIGH); 

  { 
  
 
   if (spectrumValue[0]>110)
    {
    digitalWrite (relayPin1,HIGH);
    delay (30);
    digitalWrite (relayPin1,LOW);
    }
  
  else if (spectrumValue[1]>110)
    {
    digitalWrite (relayPin2,HIGH);
    delay (30);
    digitalWrite (relayPin2,LOW);
    }
  
  else if (spectrumValue[2]>110)
    {
    digitalWrite (relayPin3,HIGH);
    delay (30);
    digitalWrite (relayPin3,LOW);
    }
    
  else if (spectrumValue[3]>110)
     {
     digitalWrite (relayPin4,HIGH);
     delay(30);
     digitalWrite(relayPin4,LOW);
     }
     
 else if (spectrumValue[4]>110)
     {
     digitalWrite (relayPin5,HIGH);
     delay (30);
     digitalWrite (relayPin5,LOW);
     }
       
else if  (spectrumValue[5]>110)
      {
      digitalWrite (relayPin6,HIGH);
      delay (30);
      digitalWrite (relayPin6,LOW);
      }
      
else if (spectrumValue[6]>110)
     {
      digitalWrite(relayPin7,HIGH);
      delay (30);
      digitalWrite (relayPin7,LOW);
     } 
  
}   
 
    
   }
}

Why is this "Urgent urgent"?

I have just spent about 10 minutes merging together all your threads on this topic of the MSGEQ7.

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Do not keep starting new threads!

  • Moderator

DvdDoug here is that code for review. I am grateful to the Arduino community for all the help

int analogPin = A1; // MSGEQ7 OUT 3
int strobePin = 11; // MSGEQ7 STROBE 4
int resetPin = 12; // MSGEQ7 RESET 7 
int spectrumValue[7];
 
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;
 


// RELAY pins, connected to pins on the Arduino
int relayPin1 = 2;
int relayPin2 = 3;
int relayPin3 = 4;
int relayPin4 = 5;
int relayPin5 = 8;
int relayPin6 = 9;
int relayPin7 = 10;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  
  pinMode (relayPin1,OUTPUT);
  pinMode (relayPin2,OUTPUT);
  pinMode (relayPin3,OUTPUT);
  pinMode (relayPin4,OUTPUT);
  pinMode (relayPin5,OUTPUT);
  pinMode (relayPin6,OUTPUT);
  pinMode (relayPin7,OUTPUT);
  
  digitalWrite (relayPin1,LOW);
  digitalWrite (relayPin2,LOW);
  digitalWrite (relayPin3,LOW);
  digitalWrite (relayPin4,LOW);
  digitalWrite (relayPin5,LOW);
  digitalWrite (relayPin6,LOW);
  digitalWrite (relayPin7,LOW);
  
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
 
  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}
 
void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite (resetPin,HIGH);
  digitalWrite(resetPin, LOW);
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
  
    
    digitalWrite(strobePin, LOW);
    delayMicroseconds(2); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);
 
    digitalWrite (strobePin,HIGH); 

  { 
  
 
   if (spectrumValue[0]>110)
    {
    digitalWrite (relayPin1,HIGH);
    delay (30);
    digitalWrite (relayPin1,LOW);
    }
  
  else if (spectrumValue[1]>110)
    {
    digitalWrite (relayPin2,HIGH);
    delay (30);
    digitalWrite (relayPin2,LOW);
    }
  
  else if (spectrumValue[2]>110)
    {
    digitalWrite (relayPin3,HIGH);
    delay (30);
    digitalWrite (relayPin3,LOW);
    }
    
  else if (spectrumValue[3]>110)
     {
     digitalWrite (relayPin4,HIGH);
     delay(30);
     digitalWrite(relayPin4,LOW);
     }
     
 else if (spectrumValue[4]>110)
     {
     digitalWrite (relayPin5,HIGH);
     delay (30);
     digitalWrite (relayPin5,LOW);
     }
       
else if  (spectrumValue[5]>110)
      {
      digitalWrite (relayPin6,HIGH);
      delay (30);
      digitalWrite (relayPin6,LOW);
      }
      
else if (spectrumValue[6]>110)
     {
      digitalWrite(relayPin7,HIGH);
      delay (30);
      digitalWrite (relayPin7,LOW);
     } 
  
}   
 
    
   }
}