Arduino Uno Wind Speed Way 2

#include <math.h>
#include <millisDelay.h>

#define windSensorPin 2
millisDelay timerDelay;

int windCounter = 0;
float windSpeedM = 0;
float windSpeedK = 0;
int windPulse = 0;
int pulses = 0;
int startTest = 1;
int windTest1 = 1;
int windTest2 = 0;
int windTimer = 1;
int result = 1;

int timerStart = 1;

void setup() {
// Set console baud rate
Serial.begin(19200);
pinMode(windSensorPin, OUTPUT);
// pinMode(RainPin, OUTPUT);
// pinMode(windDirectionPin, INPUT);
delay(10);

}

void loop() {
if (digitalRead(windSensorPin) < 1 && startTest == 1 )
{
// windDirValue = analogRead(windDirectionPin);
// windDir = map(windDirValue, 1, 1024, 1, 5000);
windTest1 = 1;
windTest2 = 1;
windTimer = 1;
result = 1;
startTest = 0;
}
WindSpeed();
if (digitalRead(windSensorPin) < 1 && timerStart == 1)
{
timerDelay.start(3000);
result = 1;
timerStart = 0;
}
if (timerDelay.justFinished() && result == 1)
{
windSpeedM = 1.25 * (pulses/3);
windSpeedK = windSpeedM * 1.60934;
Serial.print(“WindSpeed: “);
Serial.print(windSpeedM);
Serial.print(” mph tt”);
Serial.print(windSpeedK);
Serial.println(” kphtt”);

// Blynk.virtualWrite(V2,windSpeed);
pulses = 0;
windSpeedM = 0;
startTest = 1;
result = 0;
timerStart = 1;

}

}
void WindSpeed()
{
if (digitalRead(windSensorPin) < 1)
{
windCounter++;
}
if (windCounter > 0 && digitalRead(windSensorPin) == 1 && windTest1 == 1)
{
windPulse += 1;
windCounter = 0;

}

if (windPulse == 3 && windTest2 == 1)
{
pulses += 2;
//Serial.println(pulses);
windPulse = 0;
}

}

ref:https://community.createlabz.com/knowledgebase/mini-weather-station-rain-gauge-wind-speed-wind-direction-using-blynk-and-sim800c/