I am trying to setup 20 input switches that can be pressed with hand. I am trying to get the output based on the pattern in which the input switches are pressed with the hand. Based on the pressure and the area of the hand pressing the input switches, there can be multiple switches that can be pressed to display the output pattern at the same time. How can I use Arduino Uno inputs to support these multiple pin reads at the same time?
-
You could use all your Uno pins, but none would be left for the output. Or you could use a parallel in serial out shift register.– Edgar BonetCommented Jul 8, 2016 at 14:43
-
2Using a matrix is probably the best route - just like a keypad. 5x4 (9 pins) gives you 20 buttons with no extra hardware needed.– MajenkoCommented Jul 8, 2016 at 16:07
2 Answers
You could use a MCP23017 or similar. Its an IC that provides 16 IO ports via I2C, I think you can have 4 of them so that should be enough for both hands.
Or you could use resistors. All the buttons are connected to a single analogue port. The resistors are chosen so that when you press any combination of buttons you will get a unique reading at the port. So if you press button one and get a reading of 100, press 2 and get 150, press 3 and get 200, etc. So buttons 1+2 give you 250, 2+3 gives you 350 and 1+2+3 gives you 450. The problem with this is the maths get out of hand very quickly and the IC is < $1.
I'd second the use of the MCP23017, have used this chip in several projects with good results, you can connect 8 of them together which gives 128 I/O pins. Off the SDA/SCL pins UNO R3 Link Adafruit MCP23017
Also on Ebay from other suppliers.