I often run into Arduino applications that deal with realtime events. It is rather easy to write code that causes these events to be missed. Here is one way to solve the problem that avoids running at interrupt level.
If you are interested, please see
Your comments are welcome. All of us are smarter than any one of us.