Path: EDN Asia >> Design Ideas >> IC/Board/Systems Design >> Monitor 15 contacts with a single PIC input
IC/Board/Systems Design Share print

Monitor 15 contacts with a single PIC input

13 Nov 2014  | Benabadji Noureddine

Share this page with your friends

There are already a number of articles [1-4] that show how to use many pushbuttons with a minimum number of inputs. They require an RC circuit where the timing can be measured to identify which pushbutton has been pressed, or an ADC input, with resistors forming a divider for each pushbutton pressed.

The following design idea shows another simple way to use up to 15 pushbuttons with only one I/O. The microcontroller chosen must contain an internal comparator with selectable values for the internal voltage reference VREF. The majority of 8bit PIC microcontrollers in the mid-range family feature one or two internal comparators with just this.

Figure: Sense 15 buttons with one input.

As a simple and practical example, the circuit in the figure uses an 8bit PIC controlling a 4bit LED display to show which button has been pressed. A comparator interrupt routine reacts immediately to any pushbutton pressed. The routine cycles through VREF values until the comparator output COUT returns high, which will indicate the pushbutton pressed.

The fully commented assembler source code takes less than 100 words. It is not overly optimised, so as to simplify understanding and make translation to other controllers easy.

[1] Bernhard Linke: Sense multiple pushbuttons using only two wires

[2] Petre Petrov: Measure two resistive sensors or multiple switches with a single Schmitt

[3] AN234: Hardware techniques for PICmicro microcontrollers (MICROCHIP | 2003)

[4] Tips'n tricks for 8-pin PICmicro microcontrollers (MICROCHIP | 2003)

To download the PDF version of this article, click here.

Want to more of this to be delivered to you for FREE?

Subscribe to EDN Asia alerts and receive the latest design ideas and product news in your inbox.

Got to make sure you're not a robot. Please enter the code displayed on the right.

Time to activate your subscription - it's easy!

We have sent an activate request to your registerd e-email. Simply click on the link to activate your subscription.

We're doing this to protect your privacy and ensure you successfully receive your e-mail alerts.

Add New Comment
Visitor (To avoid code verification, simply login or register with us. It is fast and free!)
*Verify code:
Tech Impact

Regional Roundup
Control this smart glass with the blink of an eye
K-Glass 2 detects users' eye movements to point the cursor to recognise computer icons or objects in the Internet, and uses winks for commands. The researchers call this interface the "i-Mouse."

GlobalFoundries extends grants to Singapore students
ARM, Tencent Games team up to improve mobile gaming

News | Products | Design Features | Regional Roundup | Tech Impact