lastchancename:
NOW - WHAT ABOUT INTERRUPTS
Interrupts are very useful - especially for short-high-frequency events (not buttons#)
An interrupt uses some external (or programmed) event to literally interrupt the current program flow - to capture, mark or perform some other very simple activity.
Program execution returns and continues back where it was interrupted - as soon as the ISR (Interrupt Service Routine) has completed.
Interesting philosophy. The rules that have always been imposed on my programs in industry have been somewhat opposite. Why waste time polling for something that rarely happens (buttons)? If it occurs frequently then poll, because you are polling 20,000 time per second. Use interrupts for the buttons that occur less frequently and thus carry less overhead. Or...An absolute reason to use interrupts is to detect the change of state of anything, instantly, critically. If you are looking to measure the amount of time between occurrences (such as button presses, parts passing in front of a sensor, etc.) then one should be looking to use an interrupt. The interrupt will all the program to snapshot the timestamp closer to the event than polling will provide.