MIDI Transport Controller
Testing the Arduino Jog Sketch - Version 2
Second Test Results
This time I use the system time to help debounce the switch closures. Each time the interrupt service routine is invoked, the time of the last update is compared to the current time. If the time period is too small the interrupt is ignored. If enough time has elapsed the counter is incremented or decremented and the current time is remembered.
My initial debounce time period was 10 milliseconds. This seemed to work pretty well. So I tried again with 5 milliseconds. Again, this appeared to be a sufficient amount of time to disregard false closures. Five milliseconds is also short enough for now that I'm not concerned with reducing it further.
Test Results (ver. 2) Serial Output
0 1 2 3 5 2 1 -2 -7 -9 -13 -15 -14 -12 -13 -12 -9 -7 -5 -4 -2 0 1 2 4
There are still some slight irregularities, but overall this seems more than sufficient to use in a practical application. See the sketch code on the next page.