I would like to know how to use the pulseIn() function to read a digital signal from a reed switch that is used for bicycle speedometer. I would like to store the signal into a variable and return values such as the travelled distance and the speed. If pulseIn() is not practical, what method could you suggest?I don't think I'm clear as to how this function works. I think I need multiple pulses or a frequency. The actual distance that will be travelled is 100 feet. I am not an expert at programming I hope I can learn something here. Thanks for reading.
unsigned long SpeedoState;
int Speedo;
int SpeedoPin = 5;
int SpeedoTrip;
int PulleyDiameter = 1;
int PulleyCircumference = 3;
void setup()
{
pinMode (SpeedoPin, INPUT);
}
void loop()
{
SpeedoState = pulseIn(SpeedoPin, HIGH);
SpeedoTrip = SpeedoState * PullyCircumference;
}