Connecting over 50 push buttons with less than 10 pins

Hello, I want to connect 50 and/or more pushbuttons to my Arduino UNO. Is there any way to do this.

What exactly are you trying to do? Are these limit switches, a keyboard, etc? My first thought is to use a matrix input. The Arduino UNO has 18 usable IO. (Digital pins 2-19, 0 and 1 are used for RX and TX respectively. Don't use these unless you know what you're doing.) Using 14 pins you can make a 7x7 matrix input that can read 49 keys. Using a 15th pin gives you 56 inputs that can be read.

There are also hardware solutions for multiplexing multiple inputs onto a single line (Ex: SN74HC153N). One of these may be a better solution, depending on your intentions.

There’s also the possibility to use multiple MCP23017 16 bit IoExpanders, but at that number of IO you’d need quite a few, maybe as many as 3 or 4. That would leave you with most of the Uno pins plus 48 to 64 other pins.

These devices have pull up capability so the switches could be wired direct.

I’ve not tried more than two ioexpander devices on one board but there’s no reason 3-4 wouldn’t work.

@OP

Another option for you.

You can connect 8x8 = 64 Keys/buttons with Arduino UNO using Keypad.h Library; DPin-2 to 9 for the Row Lines (R0 - R7); DPin-10 to 17 (10 to 13; A0 to A3) for the Column Lines (C0 - C7). DPin-0 and 1 are left for connection with Serial Monitor/IDE; APin/DPin-A4 to A5 are left aside for other usage as needed. (A4 and A5 could be used as I2C Bus to address IO Expander chip like 8574 and I2C devices.)

keypad64.png

keypad64.png