I have 3 DIP switch packages with 8 switches each, and not enough inputs on my microcontroller. This article (you have to download the pdf to see the schematic) gives an example of what I want to do.
In the comments section, many people say the circuit won't work. I disagree; It looks like those commentators missed the fact that one of the lines is drawn as an 8 pin bus, and the fact that unused RA pins will be set as high impedance inputs. Still, I wanted to get a second opinion from the experts here!
Edit: After reading the many good answers to this question it seems my initial impression was wrong. This circuit will only work for momentary push buttons, not dip switches.
Answer
The schematic in the article is poorly drawn. I think he probably meant to imply an 8-bit bus, but the dots imply discrete connections. On top of that, there isn't a bus width called out (which would disambiguate things).
As DaveTweed points out, there is a risk of false switch closure detection in certain switch combinations unless a diode is used in series with each switch. Note that if the design requirement only requires reading one closed switch at a time, the circuit will work just fine.
No comments:
Post a Comment