cruise control on motorcycle, need to read timing between wheel RPMs on reed swi

PeterH:

PeterH:
You do not want to have any calls to loop() in your code, ever, under any conceivable circumstances. Is that clear enough? :slight_smile:

Apparently it wasn't clear enough. If your code calls loop(), it is wrong. How many ways do we need to say this?

+1

It's a bad idea to re-enter code on memory-challenged hardware. The stack can grow real fast.

As used in the IDE, setup() and loop() provides a frame for real time code able to handle multiple tasks usually under-1-ms-responsive on simple, limited microcontrollers.
You trim your code and use the right tricks, you can read-and-do a subtask 20+ times per millisecond. And just what subtask(s) to perform each time through loop() can vary completely and independently or by pattern to suit your app.
A state machine in loop() can reduce a whole lot of control code structure to simple state value changes instead. It cuts complexities and dependencies that make debugging headaches. It can exist along with other state machines, timers, and events (RX and sensors) in the Arduino setup() and loop() system.