Charliplexing allows for the greatest number of inputs to be multiplexed into a microcontroller, without the use of extra components (besides diodes). It essentially connects each pin to every other pin through a switch and a diode. And then it does it all over again with the diodes reversed. The diodes are intended to keep the pins from cross-talking, but since there are so many connections, it can not do this effectively enough. As a result, there are a number of button press combinations that will confuse the microcontroller. An example of how this happens is shown below.
Figure 1 – Example charliplexing schematic.
In this example, pin 1 is pulled low, and the data is read in on pins 2 and 3. But, as the green line shows, there are two pathways for pin 3 to be pulled low. Either both switches A and B can be pressed, or just switch C can be pressed. To compensate for this, you connect and scan only adjacent pins. In this example, that means only 4 switches can be used, but this is still more switches than you would normally get with single multiplexing or pin per switch methods.
Using Figure 1 as an example, we can show how the scanning is implemented. First, you set pins 2 and 3 to input with pull-ups on, then you pull pin 1 low and read in pin 2. Next, you set pin 1 to input with pull-ups on, and drive pin 2 low. In this case, you read both pins 1 and 3 (the adjacent pins). Finally, you set pin 1 and 2 high with pull-ups on, and pull pin 3 low. The data is then read in on pin 2. For larger matrices, you repeat the same process – only one pin is low at a time, and you only read in adjacent pin data.
This demonstrates the main drawback of charliplexing – the complicated scanning process. It takes a while to read in all of the data. But, it does allow for interrupts on a select few lines. As it turns out, the multi-touch subset of charliplexing has limited uses. It only adds extra switches for when you have between 3 and 6 microcontroller pins. For all other conditions, it does no better than single multiplexing. But, if your design does not require multiple button presses at a single time, you can use a full charliplexed matrix.