SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Roms
#135683
I would like to use the SF spectrum Analyzers data and clock outputs to control 7 relays that will be switching an AC load.
What chip(s) should be used that will take the outputs from the Analyzer and allow me to contol 7 individual relays?

Basically, I need coaching on the circuit between the Spectrum analyzer (data,clock) and the relay circuit(data x's 7).
By Roms
#135725
I cannot seem to get this to work. I am trying to get Pin 13 to turn on and off based on spectrum values.

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();
}
By esklar81
#135831
Roms,
Here are some suggestions:
  1. Go to the product page for the spectrum analyzer and read the comments. Try the code reported (in them) to work.
  2. Check to make sure you are using the correct pins. The analog and digital pins are different, and your use of a digital function (pinmode) on what you appear to consider an analog pin indicates you may have the pins a bit confused. (See the Arduino Reference for which functions apply to which pins.)
  3. Check to make sure the spectrum analyzer and Arduino have a common ground.
  4. More generally, post a schematic of how you have these things connected to each other, power, and ground.
  5. Rather than telling us it doesn't work, tell us what it does and what, that you expect or intend it to do, it does not do.
  6. Divide your problem by trying your code with values assigned by you, rather than by analog reads, to the variable.
  7. Check the outputs of your spectrum analyzer with a voltmeter.

Happy Hunting,
Eric