I have two projects where I'd like to place a custom panel of buttons (maybe 5 to 15 buttons) about 8 feet from the Arduino. I realize I could add 2 wires per button, but it would be great to reduce the wire count, as well as make it easier to add buttons in the future without running more wires.
Would setting up a multiplexer be my best bet? If so, do I need to consider anything special re: voltage drop for the 8' run?
Well, you only need 1 wire per button and a common ground, so there's a big savings there.
Each button will connect an input pin with pullup resistor to Gnd,
If the internal pullup is too weak, you can add a 10K or 5K at the chip to help.
Otherwise, you are looking at something like capturing the button states with a couple of shift-in registers with added input pullup resistors and reading the shift register with shiftIn() or SPI.transfer over several wires - power, Gnd, latch, clock, data out. 74HC165 SN74HC165N Texas Instruments | Integrated Circuits (ICs) | DigiKey
If adding more buttons, then additional shift registers could be added.
Hi,
It's common to put 4 to 6 buttons on one Analog input. 8 feet should not be a problem if you run the data and ground as a twisted pair. Or use shielded twisted pair wire with shield ground, +5 and signal in the pair.
You could also use CAT5 ethernet cable which has 4 twisted pairs of wires. one pair as +5 and Ground, and 3 pairs as signal and ground easily gives you 15 buttons using THESE little keypads. Some example with code HERE (Code Updated: Better debouncing)
Or extend a PS/2 type keyboard and have LOTS of buttons...
Thanks for the quick responses. All were very helpful.
Robin, your guide looks fantastic. After some troubles a few months ago with the RF24 library, I put my nRF24L201+ transceivers off to the side and haven't even considered them since. I'll go through your guide, as it seems to address a lot of the questions I had back then. Also, the fact that multiple can be listening is a big plus.
Is it required to know if multiple buttons are pressed at the same time? If not, the analog approach could be quite reliable (even for 15 buttons) and only require 2-wires. For 15 buttons, analog readings would be in steps of approximately 64 counts. Only 16 resistors and a capacitor needed.
dlloyd:
Is it required to know if multiple buttons are pressed at the same time? If not, the analog approach could be quite reliable (even for 15 buttons) and only require 2-wires. For 15 buttons, analog readings would be in steps of approximately 64 counts. Only 16 resistors and a capacitor needed.
That's fascinating. I see some diagrams online for using analog inputs, and the concept makes sense. That's brilliantly simple and may work very well for some of the cases. I'll try the other methods here for the more complex ones with multiple buttons at a time. Thanks for the tip.
I think the default setting for the nRF24 is high-power. I have never changed it. Mine work when they are both in the same small clearing on my work-table and I also tested a pair outdoors and they were still working at 110 metres range.
There are also high-power nRF24 modules with external antennas that can work over a much longer range. I don't have any of them.