What i am trying to do is toggle an output on the arduino, based off the presence of a 12.5khz signal.
Using the FreqCount library i am able to see this frequency represented in the serial monitor window. it prints 12680 every second when present, and 0 when not.
I am stuck trying to write the lines of code that will turn on or off my output given the above information.
This is the code i am using with the FreqCount Library
they have measure and count. in the documentation it suggest using Count instead of Measure for signals over 1khz.
Again, i have no idea what I'm really doing here.
I will attempt to implement your suggestion and post my results.
Thanks for the help…i am in WAY over my head here!
… I'm sure this seems trivial to you, but its totally alien to me.
I'm a welder/fabricator/machinist {manual}. i don't even understand the more advanced functions on my DRO.
Dials and levers are much more my speed. {i still have to microwave things for my old man, he never got it either}
I truly appreciate you knowledgeable folks taking time to stoop to our level. I know it can be really frustrating answering the same questions over and over for people that just don't get it.
But understand, without your generosity, many of us would never get farther than a blinking led.
When the frequency is sensed, the LED on the board lights up, but very dim. the external led connected to ground and pin13 does not light up at all. {it does blink on reset along with the led on the board}
also the led on the board stays dimly illuminated until i click the reset button. if i turn the generated trigger signal off, the dimly lit led stays dimly lit. it does not turn off.
const int ledPin = 13;
#include <FreqCount.h>
void setup() {
Serial.begin(57600);
FreqCount.begin(1000);
}
void loop() {
if (FreqCount.available()) {
unsigned long count = FreqCount.read();
Serial.println(count);
if(count >=10450 && count <= 14550)
digitalWrite(ledPin, HIGH); // Do whatever needs doing
}
}
As of now i have the circuit and code working satisfactorily.
My errors from above were not having the pinMode assigned as Output which was causing low current to the LED.
i also added an else statement so the pin would turn off when conditions were not met.
i made some tweaks in the timing so the circuit responds in near real time as opposed to the 1second delay.
Tomorrow my final adjustments to the code will to be to improve have fast the circuit can turn off. i don't mind a delay in turning on, as it is rather desired. But when the signal falls off, i need it to turn off immediately. May need to try FreqMeasure instead of FreqCount.
Suggestions greatly appreciated!
Again i will say, i could not have done this without the support of this forum.
Thanks PaulS, i even had that page open in the reference and was having troubles figuring it out. But for some reason, after staring at it tonight things started to click and make a little bit of sense.
Not much, But a little!
const int ledPin = 13;
#include <FreqCount.h>
void setup() {
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
Serial.begin(57600);
FreqCount.begin(10);
}
void loop() {
if (FreqCount.available()) {
unsigned long count = FreqCount.read();
Serial.println(count);
if(count >=100 && count <= 140)
{
digitalWrite(ledPin, HIGH); // Do whatever needs doing
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
}