push button selector

I want to build a midi controller that has an array of 20 push button switches similar to radio preset buttons. I have momentary button switches with leds, I’d like to have the button lite when pressed while turning on one of the functions in the midi program. Would I need anything else to do this?

Yes you would need something else besides 20 light up switches.

Without a lot more details from you on how this would actually work for you, it would be just be a guessing game for others.

20 switches in a 4 x 5 matrix and a key pad library would be a starting point. 9 pins for direct connection or 2 pins and key pad connected to I2C expanders.

20 switches and 20 lights is two problems. A larger Arduino such as a MEGA can just support this many I/O pins but even that has a problem if you want to light more than a handful of the lights. It can't output that kind of power.

The posts above have suggested repurposing a keypad controller as the input for the switches. But nobody has suggested an output method. I like the MAX6971 as it's able to drive 16 high-power LEDs and you can daisy-chain an unlimited number of them. I don't see a lot of other Arduino tutorials using it. You may find other chips more suitable for your project.

Only 1 light at a time, the 20 switches turn on 1 function at a time all others off, just like radio preset buttons

A 4x5 matrix for the buttons, and a second for the LEDs it is, then.

Remember to add the current limiting resistors for your LEDs.

A bit of a chore to wire up but it's pretty straightforward to do and implement the code to read the button and light up the corresponding LED.

wvmarle:
Remember to add the current limiting resistors for your LEDs.

I was going to call this a job for a MAX7219 module - which can control up to 64 LEDs in a matrix - but does not have to. LEDs on switches are most unlikely to be "high-power LEDs" and despite only wishing to light one at a time, the MAX7219 does it all in one. You might for example wish to run a "scan" display on the buttons.

But that said, if you really, really only wish to display one LED at a time and sense only one button at a time, then a matrix of 4 by 5 incorporating both LEDs and buttons, would require only 9 pins.

I of course expect someone to interject that if you connect the button across the LED, then the LED will not be able to light while the button is pressed, but there is a very elegant way to avoid that problem with no extra components. :grinning: Of course you need five resistors for current limiting to the LEDs.

Hi,
Are the buttons, press ON momentary OR press ON - press OFF type?

Can you post a link to data and/or a picture please?

The type of LED lit button is very important.

Thanks… Tom… :slight_smile: