I am learning along here, i am trying out different float, unsigned longs etc... i have also got my "cheat-code" to work... i tried the freqmeasure.h and that worked like a charm...
don´t get me wrong here, i like to learn and i am listening to all of you! big thumbs up for you guys! So while i try to compile my "own" code i also trying librarys with examplecode...
just sharing what i tried yesterday, i also tried to add a button so i can choose when i want to take a reading.
#include <LiquidCrystal.h>
#include <FreqMeasure.h>
#include <Math.h>
LiquidCrystal lcd (12, 11, 10, 9, 7, 6);
float Msqm;
const float A = 22;
int buttonSQM = A2;
void setup() {
Serial.begin(19200);
FreqMeasure.begin();
pinMode(buttonSQM, INPUT);
digitalWrite(buttonSQM, HIGH);
lcd.begin(16,2);
}
double sum=0;
int count=0;
void loop() {
if (buttonSQM = digitalRead(HIGH));{
if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
double frequency = F_CPU / (sum / count);
Serial.println(frequency);
sum = 0;
count = 0;
Msqm = A - 2.5*log10(frequency); //Egen Kod
Serial.print(Msqm);
Serial.println(" Mag/Arcsecond2 ");
}
}
}
}