KeyDetector Library - Multiplexed digital signals detection

Hello everyone!

I want to share small library I wrote as a means to decode multiplexed digital signals transmitted through single analog line: KeyDetector.

The possible case to use this library: if you are running low on a free pin budget, but still need a way to receive multiple control signals, you may opt to use DAC on the transmitting end and multiplex the encoded control signals into single analog line that will be decoded on the receiving Arduino.

KeyDetector library can make decoding process a little easier: you specify desired signal levels and on which analog pin you are waiting this levels to be detected.

For example you may want to transmit several digital signals from control panel (or, say, gamepad) equipped with multiple buttons using single wire. Each signal level in this case may represent specific button of the panel being pressed. When KeyDetector detects these specific signal levels, special object will be populated with the currently detected signal, so you may invoke actions based on button being pressed. It also tracks what signal was detected previously and can detect continuous button presses.

The library is small and simple, and provided with all necessary documentation and annotated examples, as well as Wiki section on GitHub that features additional illustrated guides for the supplied examples.

One of the examples demonstrates the way the library can be used to decode signals from PS3 controller connected via Bluetooth to the other Arduino, equipped with USB Host Shield. This is actually an application I’m using this library for - that way I am able to free some space on the main Arduino board and use only one wire to transmit states of multiple digital buttons.

Another basic examples show how to build absolute rotary encoder using potentiometer and KeyDetector library and how to detect momentary push-buttons single and continuous presses.

This is my very first library written for Arduino, so I’ve decided to give it a shot and publish it (and practice in writing the documentation along the way). Hopefully someone will find this one useful=)

Any feedback is highly appreciated (including the one regarding English grammar;))!

Thank you!

As a small update to PS3 controller example, I've created small shield for Arduino Pro Mini that hosts three Low-pass filters (on pins 3, 5, 6) and 3-bit DAC (similar to one used in the example). For more detailed info (including Fritzing files) see updated entry in KeyDetector Wiki.

Hi everyone!

Recently updated KeyDetector with some new features:

  • Support for detection of up to two simultaneously pressed keys connected to digital pins;
  • New properties: triggerRelease (to track key release event), secondary and previousSecondary (for secondary key detection);
  • New example to show possible use with rotary encoder;
  • Timing diagrams in Readme (to illustrate order in which properties of KeyDetector object are populated).

Updates available in release 1.2.0.

:wave: Examples now can be found (and played with) on Wokwi simulator!

1 Like