[HELP] Midi button LED control code.

That looks a lot like my project Mini Monome but with a direct MIDI output.

So the first thing you need to know is what note corresponds to what push button. Build that into an array and use it as a look up table.

Then you need to draw a schematic of your circuit, have you got 32 I/O lines free on your processor or do you need some multiplexing?

Then it should be a simple matter of scanning through the buttons and any you find pressed outputting the MIDI note on message with the note number from the array and turning off the corresponding LED. Then on release turning on the LED and sending the MIDI note off message.

Things to worry about is can the Teensy supply enough current to turn on all 16 LEDs at the same time. If each LED takes 20mA then that would be 320mA which would be too much for a Mega. The absolute maximum for various pin combinations should be in the data sheet. If you don’t have enough current available then you will need a transistor or Darlington driver to boost the output current.

Edit:- sorry just looked at your origional post and seen you only need 5 LEDs so you should be OK for current. But what exactly will determin the cut off LED pattern, do you want it random, fixed by a table or related to the MIDI note number somehow?

You could use a Neopixel strip along each acrylic edge for extra colourful LED flashing fun.