Multi-Button Input

Multi-Button Input

Introduction

When working with microntrollers, digital input pins are usually used to interface with buttons. This works fine if you have a digital input pin available for each button you want to use. Unfortunately in some situations extra digital pins are not always available for use. If you need to use multiple buttons for input but don't have enough digital pins, you might be able to use a multi-button input circuit. This circuit will allow you to get input from a large number of buttons and only requires the use of a single anlog input pin. Depending on what you need to accomplish, you can configure the mulit-button input circuit to your needs. It is possible to design the circuit so it will only keep track of how many buttons are being pressed at a time. If you need to know whether a specific button or combination has been activated, you can configure the circuit to generate a unique voltage for each button/combination.

How it Works

At its core, a multi-button input circuit is actually just a variable voltage divider; each button has a resistor associated with it. This means whenever a button is pressed, it will add resistance to the circuit. In Fig. 1 take note of how resistors R1 - R4 are placed in parallel with one another. This parallel placement means their resistances will also be summed in parallel (follow the orange tab for more info about parallel elements). The parallel button resistors work in conjunction with with R5 to form a voltage divider. As the summed resistance of the parallel resistors change, so does the output voltage of the voltage divider. If you want to learn more about how voltage dividers work, follow the red tab on the right.

Test it yourself!

Figure 1 below illustrates how a multi-Button input circuit would work. The figure is interactive so try clicking the buttons to see how the circuit works. The figure lets you experiment with two circuit configurations. The first configuration is very simple to build since it only uses 220 Ω resistors. This produces a unique voltage depending on how many buttons are pressed. The second configuration uses a different resistor value for each button. This produces a unique voltage for each button and button combination. You can switch between circuit configurations by clicking the box in the top right corner of the figure.

Figure 1. Interactive Multi-Button Input Circuit.

NOTE: For demonstrative purposes, this simulation calculates the voltage using ideal resistor values. It does not account for the ±5% variance real resistors have. Because of this, building the circuit depicted in Fig. 1 may produce slightly different voltages than shown.


  • Other product and company names mentioned herein are trademarks or trade names of their respective companies. © 2014 Digilent Inc. All rights reserved.