Monday, 22 September 2014

multiplexer - Multiplexing Inputs on a microcontroller


I have a 4 way DIL switch that I use to provide input to a microcontroller, and I need to free up a port to use for something else.



Is there a way to multiplex 4 inputs into 3 microcontroller ports? I'm thinking that there may be some way to have 2 pins as inputs, and a 3rd output pin that can be driven high to read switch 1 and 2, and low to read switch 3 and 4.


My current simple design is shown below, can I do this with just 3 pins?


schematic



Answer



Charlieplexing takes advantage of tristate pins of the microcontroller, but it costs extra diodes and somewhat more complex programming.


With N IO-pins you can address N(N-1) switches / LED's.


The Charlieplexing with switches article describes how it works with switches and LEDs


Tree pin and 6 switch Charlieplexing


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...