Hello, I am a French student. I try to measure the speed of an object. I use te following program :
#include <FreqMeasure.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(57600);
lcd.begin(16, 2);
lcd.print("Freq:");
lcd.setCursor(10,0);
lcd.print("Speed:");
FreqMeasure.begin();
}
double sum=0;
int count=0;
void loop() {
if (FreqMeasure.available()) {
// average 30 readings together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
float frequency = FreqMeasure.countToFrequency(sum / count);
float spd = frequency / 19.49;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(frequency);
lcd.print("Hz");
//lcd.print(" ");
lcd.setCursor(8,1);
lcd.print(spd);
lcd.print("km/h");
sum = 0;
count = 0;
}
}
}
But I havea problem, the does not wokit seems that lack a file from the Library. Someone could explain me how to solve this problem.
#include <FreqMeasure.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(57600);
lcd.begin(16, 2);
lcd.print("Freq:");
lcd.setCursor(10,0);
lcd.print("Speed:");
FreqMeasure.begin();
}
double sum=0;
int count=0;
void loop() {
if (FreqMeasure.available()) {
// average 30 readings together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
float frequency = FreqMeasure.countToFrequency(sum / count);
float spd = frequency / 19.49;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(frequency);
lcd.print("Hz");
//lcd.print(" ");
lcd.setCursor(8,1);
lcd.print(spd);
lcd.print("km/h");
sum = 0;
count = 0;
}
}
}
But I havea problem, the does not wokit seems that lack a file from the Library. Someone could explain me how to solve this problem.