Installing more IOs on a device

Hi
I have a 2560 which has about 50 or so IOs for what I'm trying to do
I have 30 buttons that will control 30 LEDs. Can't use an addressable LED since each LED is at a different location (think passenger call button on a plane - each button sends a signal to the attendant's point to make a noise and each LED lights up in the seat).

This is similar to what I want to do. The programming works (tried with 10 LEDs by 10 buttons) but I'm out of IO ports. How do I expand past this? Is there an expansion shield that can help here? Maybe something similar to those addressable LED strips but with IOs instead of just lighting up?
TIA

You could use i2c based pcf8574 8 bit io expanders. You could have up to 16 of those using the two chip variations and one address for each device. There are also 16 bit io expanders too but I've only used 8 bit versions.

On the mega you use the wire library to address them and send io commands.

They are available in through hole form for easy prototyping.

You could try a resistor ladder for all of those buttons to only use one pin.
Imagine a potentiometer that returns 0-1023. Imagine each position was instead a button. Theoretically 1023 buttons can be put on a single pin. 30 buttons is definitely doable.

Thanks.

I thought of the resistor ladder but the problem there is that if two buttons are pressed together the value will change so I have to look out for every combination pressed, which I felt was too much work. I could ignore multiple buttons but I'd prefer not to

I also saw the i2c expanders, but for some reason didn't try it. Guess I'll try that and see

Thanks again

Arrange your buttons and LEDs into matrixes. This will dramatically reduce the number of pins you need.

For your buttons, you could organise them into a 6x5 conventional matrix, so 11 pins needed. Alternatively, if you solder a diode to each switch, you can arrange them as a charlieplexed matrix, requiring only 6 pins. That means you could use cat5 cable.

For your leds, also organised into a 6x5 matrix, you will need a chip of some kind or some transistors to help drive your leds so they are bright enough. You could buy a ready made max7219 module which would require only 3 Arduino pins. Or you could use a uln2003 to drive your matrix using 11 pins. Or you could make your led matrix also charlieplexed, using 6 npn transistors and 6 pins.

If you don't want to go down the matrix route, you could use 4 X 74hc595 to drive the LEDs and 4 X 74hc165 to read the buttons. This would require 4 Arduino pins (the SPI bus pins, plus any other digital pin as the "latch" line).

Interesting .... Never knew about this.

Will give it a shot for sure.
Time to do some research

Thanks!