Frequently Asked Questions
Mon-Fri, 9am to 5pm
U.S. Mountain Time:
Chat With Us
October 12, 2012
Tutorial - Processor Interrupts with Arduino
about 3 years ago
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 https://en.wikipedia.org/wiki/Static_variable 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: https://www.sparkfun.com/products/9117
It would take a lot of finger-gespinning to take up all the CPU with that…
Forgot your password?
No account? Register one!