Help!-Spectrum analyzer signal output to pin13

Total noob.

I cannot seem to get this to work. I am trying to get Pin 13 to turn on and off based on spectrum values so I can activate a relay
I left the serial.print code in there with the intent that I would use that to find the each band level and make adjustments. Suppose I need to get there first!
ie. Pin ON <100
Pin Off >100

int analogPin = 0; // read from multiplexer using analog input 0
int strobePin = 4; // strobe is attached to digital pin 4
int resetPin = 5; // reset is attached to digital pin 5
int spectrumValue[7]; // to hold a2d values
int digitalpin1 = 13;

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

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

}

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

for (int i = 0; i < 7; i++) //i is equal to 0, if i is less than 7(bands from analog pin0) repeat loop until it equals 7.
{
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // to allow the output to settle
spectrumValue = analogRead(analogPin);
// comment out/remove the serial stuff to go faster
// - its just here for show
if (spectrumValue < 10)
{
Serial.print(" ");
Serial.print(spectrumValue*);*
//digitalWrite(13, HIGH);
}
else if (spectrumValue < 100 )
{
Serial.print(" ");
Serial.print(spectrumValue*);*
digitalWrite(digitalpin1, HIGH);
}
else if (spectrumValue > 100 )
{
digitalWrite(digitalpin1, LOW);
}
else
{
Serial.print(" ");
Serial.print(spectrumValue*);*
//digitalWrite(digitalpin1, HIGH);
}
//digitalWrite(digitalpin1, HIGH);
digitalWrite(strobePin, HIGH);
}
Serial.println();
}

You need

  pinMode (digitalpin1, OUTPUT) ;

in setup.

Ty Mark-

Well that got things going. I am reading the pin out voltage which is fluctuating from 1.3v to 4.5. (based on spectrumValue). I was hoping for an off/off response.

else if (spectrumValue > 110 )

  • {*
  • Serial.print(" “);*
    _ Serial.print(spectrumValue*);_
    _
    digitalWrite(digitalpin1, LOW);_
    _
    }_
    else if (spectrumValue > 100 )
    _ {
    Serial.print(” ");
    Serial.print(spectrumValue);
    digitalWrite(digitalpin1, HIGH);*_

5V should return 1023 and 1.3V should return 266 and you're checking around 100-110....