Quick Summary
Additional Context
We all have been there. We ran out of GPIO pins on our favorite microcontroller. Switching to a type with more pins wasn’t possible. Perhaps we were space- or cost-constrained. Or perhaps we didn’t want to port the code to a new microcontroller. Or perhaps we wanted the engineering challenge to make it work with fewer GPIO pins.
I recently encountered this situation. I had six switches but only two GPIO pins left. Another requirement was that I wanted to be able to detect not just single button presses but also two buttons pressed simultaneously. It was for a handheld device. Since we have two thumbs, it is very easy to press two buttons at the same time. For example, in a D-Pad with four buttons, up, down, left, and right, one can input the diagonal directions by pressing two adjacent bu