Rotary Encoder - learn this if you have about 400 hours of time.

"blink without delay" is your friend.
Note the time, start an action, monitor the time to see when to stop the action.