Integration test: combined input from several buttons and a rotary encoder
March 19, 2026 ยท View on GitHub
Purpose and summary
To test correct identification and combination of events caused by different kinds of digital inputs. Individual events are combined into a global state bitmap (one bit for each input).
Hardware setup
Use this test circuit:

We are using the KY-040 rotary encoder and the button matrix.
Output through USB serial port at 115200 bauds.
For later reference:
-
"BM1" is the button in the matrix whose output is:
STATE : 0000000000000000000000000000000000000000000000000000000000000100 -
"ROT" is the built-in push button in the rotary encoder.
-
"RCW" means rotary clockwise rotation.
-
"RCCW" means rotary counter-clockwise rotation.
Procedure and expected output
-
Reset
-
On start, output must match the following:
-- READY -- -- GO -- STATE : 0000000000000000000000000000000000000000000000000000000000000000 -
Press and hold ROT, then press and hold BM1, then release ROT, then release BM1. Output must match the following:
STATE : 0000000000000000000000000000000000000000000000000000010000000000 STATE : 0000000000000000000000000000000000000000000000000000010000000100 STATE : 0000000000000000000000000000000000000000000000000000000000000100 STATE : 0000000000000000000000000000000000000000000000000000000000000000 -
Input RCW one detent, then RCCW one detent. Output must match the following:
STATE : 0000000000000000000000000000000000000000000000000001000000000000 STATE : 0000000000000000000000000000000000000000000000000000000000000000 STATE : 0000000000000000000000000000000000000000000000000010000000000000 STATE : 0000000000000000000000000000000000000000000000000000000000000000 -
Press and hold ROT, input RCW one detent, then RCCW one detent, then release ROT. Output must match the following:
STATE : 0000000000000000000000000000000000000000000000000000010000000000 STATE : 0000000000000000000000000000000000000000000000000001010000000000 STATE : 0000000000000000000000000000000000000000000000000000010000000000 STATE : 0000000000000000000000000000000000000000000000000010010000000000 STATE : 0000000000000000000000000000000000000000000000000000010000000000 STATE : 0000000000000000000000000000000000000000000000000000000000000000