Leonardo - How to Get 20 Inputs?

Hi Folks,

I'm currently in the final stages of putting together my Leornardo-based MIDI controller. Thanks to the advice I received here it all went well (actually it was amazingly simple to put it together).

The MIDI controller has 12 pots and 8 buttons. I was under the assumption that I can get 20 inputs with the Leonardo. What I'm unclear about is how to do this. Currently, I've got the 8 buttons going in to the digital inputs. The pots are going into A0 - A5 and 8,9,10 and 12. So I'm left with 2 pots - I'm not clear where they go? Do they go to the Digital 4 and 6 inputs? If so, where do the two buttons that were using these inputs go?



Yes. Pin 5, 7, 11, 13 are digital.


Yes. Pin 5, 7, 11, 13 are digital.


So two buttons go to 11 and 13, and the pots then go to their inputs? At the moment I'm using some code (can't remember exactly where it came from) that's using:

int ledPin = 13; // choose the pin for the LED

I guess I can change this but it's handy to see when MIDI is being sent.

What could I use for the LED?


Interfacing 12 pots and 8 buttons leaves no I/O pin left for any LED as I can see in the data sheet.

OK, I can drop the LED, it's handy but not essential.


I hardly think I'm wrong, being an UNO user but wait for a day if a Leonardo specialist corrects me.

You could wire your 8 buttons as a 2x4 matrix, requiring only 6 pins. Or a 3x3 matrix, allowing for a 9th button if you like. If multiple buttons need to be pressed simultaneously, then to avoid "ghosting" you will need to wire a small signal diode in series with each button.

The Leonardo has 3 more digital pins broken out on the ICSP header, see https://content.arduino.cc/assets/Pinout-Leonardo_latest.pdf#page=3. You can refer to them using MISO, SCK and MOSI in your code.


Hi All,

I’m happy to report that MIDI controller is finished and working!

Thanks for the help provided here.

I ended up getting two Leonardos so I’m currently thinking about making some other sort of controller but not sure what.


Well, we could have warned you not to do that. Next time get a Pro Micro. Much more practical, for prototyping on breadboard and for the final build.