Hi Everyone,
So, I had posted before about help with my sketch, although now I have cleaned it up a bit and need some help again. This time I am wondering how to create/call the frequency function correctly. The original code is from: Page has moved
What I wrote is below, although I am not getting any results. The problem, most likely, is that I am not actually getting the frequency to read.
#include <FreqCounter.h>
void setup() {
Serial.begin(9600);
Serial.println ("");
}
void loop() {
Serial.println("");
Serial.print("Frequency: ");
printFreq();
Serial.println(" Hz");
Serial.print("Pressure: ");
printPress();
Serial.println(" PSI");
delay(6000);
}
double Frequency() {
long int frq;
FreqCounter::f_comp = 8;
FreqCounter::start(1000);
while (FreqCounter::f_ready == 0);
{/*Do Nothing*/}
frq=FreqCounter::f_freq;
return frq;
}
double Pressure() {
double frq = Frequency();
double A = -4.170459900908042e-11;
double B = -0.04637910393309745;
double C = 1765.6201656883327;
double Press = ((A*frq*frq)+(B*frq)+C);
return Press;
}
void printFreq (void) {
delay(50);
double freq = Frequency();
}
void printPress(void) {
delay(50);
double Press = Pressure();
}