short on input pins?
Here’s one I read the other day.
It could be that it was mentioned already in the community, but hey! it does not hurt
(I’m pretty sure PK or Andreas would tell me where is that post)
Of course they mention a PIC, but I do not see why one could not use this on a Particle Device.
Source is here.
Carl Dreher wrote:
I’m working on a RF remote with a display. Been looking at the PIC12LF1840T39A single-chip transmitter/mcu. Very inexpensive, low power, etc. I have a “joystick” switch in mind, which is five on/off switches in a single package. The problem is, the PIC device doesn’t have enough I/O for five individual switches, plus the I2C I need for the display. That is when I stumbled across this idea:
Switches connected to ADC
The voltage at the ADC changes depending on the switch pressed. The values shown present from 0% to 80% of VCC. The PIC has a 10-bit ADC, so detecting the right value is easy. Heck, you could extend this out to a dozen switches! And if you really want to go crazy, you can detect multiple keys being pressed if you swap the 0K resistor to something like 1K.
The downside of this is that you have to poll the ADC, which consumes power. BUT…the PIC also has a comparator input. So if you really want to save power, just run the voltage divider into the comparator and wake up the processor when it crosses below 90%.
The PIC also has a sneaky mode you can put it in where the ADC continues to work while the chip is asleep, so you could put it in that mode, wake up when the ADC finished and go back to sleep. Not as efficient as using the comparator, but saves a pin.
I need to tell you where I idea came from. MicroChip has a development kit for the PIC12LF1840T39A, and the document associated with it is “Wireless Security Remote Control Development Kit User’s Guide”. On page 35 is a schematic for the keyfob that comes with it, and I puzzled over it for quite awhile. Two of the four pushbuttons on the keyfob go directly to I/O ports as expected, but two other go to one pin with a resistor divider. That is when this occurred to me. Wish I could claim it is my idea. Well, maybe I can claim to have popularized it