i am newbie in arduino and i have small project i read that pulsein() function return length of the pulse in microseconds and
frequency(HZ)=1/time(second)
so i hope below code to measure frequency value is correct otherwise please notify me
nt Htime; //integer for storing high time
int Ltime; //integer for storing low time
float Ttime; // integer for storing total time of a cycle
float frequency; //storing frequency
void setup()
{
pinMode(8,INPUT);
serial.begin(9600);
}
void loop()
{
Htime=pulseIn(8,HIGH); //read high time
Ltime=pulseIn(8,LOW); //read low time
Ttime = Htime+Ltime;
frequency=1000000/Ttime; //getting frequency with Ttime is in Micro seconds
Serial.println(frequncy)
delay(1000);
}