Middlesex County, Ontario | You capture and record the time when the signal goes high, then capture and record the time the signal goes low, subtract the high time from the low time, and you have the duration.
There is a built in and very easy function called pulsin() that returns the length of a pulse on a pin in microseconds. https://www.arduino.cc/reference/en/language/functions/advanced-io/p...
A more robust (and more advanced) way to do it is with interrupts. |