I usually counsel against
using interrupts unless you need to respond to something fast
, and revolutions of a bicycle wheel is anything
but fast in computer terms.
The problem here though is that you have a loop with two delays in it.
put delays in counting code because you are not counting while you perform the delay. Either you decide to count for a certain period and then (stop
counting while you) display the result, or you will
need to use interrupts - for both
counting the events and
determining the counting "window", which gets much
With reed switches, you will need to consider debouncing in order to actually
do the counting - of course, the present limitation has restricted you from seeing such errors.