Member Since: October 12, 2012

Country: United States

  • I agree with Signal7. The last_button_time variable is only touched when initialized, and when it is checked or set within the ISR function. A static variable with function scope is ideal. See for a good description.

    The button_time variable could be a stack variable or static with function scope as well, just to minimize stack use during the ISR. Not a big deal with non-reentrant ISRs; either way is fine.

    Also, where are the pinMode() calls in setup()? Am I missing a reference somewhere that explains the default state of each pin and why it’s not necessary to set pin2 to INPUT or 13 to OUTPUT?

  • I think Scharkalvin was speaking of this kind of rotary encoder:

    It would take a lot of finger-gespinning to take up all the CPU with that…