Arduino users are, typically, blessed by an embarrassment of inputs and outputs. The Arduino Uno, by far the most popular model, packs a whopping 14 digital input-output pins and a further six analogue inputs, and for those who find that too restrictive the Arduino Mega increases this to 54 digital and 16 analogue pins. Sometimes, though, a project becomes complex enough that you run out - or perhaps you're building around an ATtiny or other Arduino-compatible chip with far fewer user-accessible pins.
There are a number of methods to resolving a lack for pins, including shift registers and charlieplexing, but maker Ron Miller's latest project showcases one that is very clever indeed: reading four button inputs on a single analogue pin. At this point, the more experienced Arduino user will likely be shouting at the screen that this is nothing particularly special - until, that is, we point out that Ron's solution allows for full N-key rollover, or the ability to press multiple buttons simultaneously.
Traditional row-scanning, used for keypads and keyboards for decades, requires at least two inputs and falls down when it comes to simultaneous button presses. Depending on how the feature is implemented, you're either limited to single key presses or a small number of keys sharing rows or columns. Ron's method, by contrast, uses what he calls a "double-Y configuration" of buttons and resistors, such that the resistance is unique for each possible combination of buttons. With a unique resistance to each combination, the analogue pin reads a different voltage; with that knowledge, it's simple to interpret any combination of key presses.
Ron's implementation of the double-Y button scanning system demonstrates its capabilities in a single-dimension 'line' game of his own creation. While its complexities don't scale well for larger numbers of buttons, if you need a cheap and easy way to read up to four button combinations into your next sketch you would do well to check out his Instructable and play around with the provided code.
This Instructable focuses on using one analogue input line for multiple buttons which can be detected independent of each other. Here with what I call a Double-Y configuration of four buttons & resistors, you can reliably discern any single, double, even triple or all four buttons being pressed.