Button Box with displays - Multiplexing and which arduino?

Hi everone,

I am new to the forum and I have already done some research but now I am stuck with some more specific questions.

Here is what I want to do: Build a button box for sim games that features many push buttons and toggle buttons, 5 Potis and multiple OLED displays showing text or simple animations.

For the displays I wanted to use 0.96 inch OLED displays that are controlled via I2C. Since they all have the same address, a multiplexer will be needed (something like a 74HC4051).

As I have planned ~40 buttons (not exactly sure here) I think I need some sort of multiplexing.

The whole box should be recognized by the PC as a joystick or similiar.

Now my questions:

1) Which arduino model would you suggest? I am not sure how big the program code will be, most likely I have to include the libraries for display control. The code for button handling should be rather small. Do I need to worry about amount of needed current when using 6-8 small OLEDs?

2) For which kind of multiplexing would you go? I would like to keep things simple here and thought about a matrix with 7x7 or 8x8 inputs (limits my choices for arduino models). The other idea was a input/output expander of some sort.

3) I read that the leonardo and micro allow being recognized as "HID" in a PC, others said "keyboard". I need my board to show up as joystick, however. A "keyboard" would not allow analog input from the potis, right? So at this point, I am not sure which arduinos allow for that functionality...

4) Did I understand it correctly that the inputs of the arduinos have "built-in button debounce"? Like a pullup resistor or a software solution for it? Does somebody know whether input/output expanders can have that, too?

Sorry for the amount of questions. I am already happy, I someone could help me answer just one of these! Cheers :-)

If you want 40 buttons, you could get a host usb shield. I mean something like this. Connect an old keyboard to it and define in your code what the keys of this keyboard should do. At the same time you could register your Arduino Lenardo (or Micro) as an HID device when its plugged into a computer.

For the potis, you might be able to simply use rotary encoders instead: [ Rotary encoders run on digital pins and not on analog pins.

I read the leonardo and micro allow being recognized as "HID" in a PC, others said "as keyboard". Which one is right?

Both. https://www.instructables.com/id/Create-a-Joystick-Using-the-Arduino-Joystick-Libra/ https://www.sparkfun.com/tutorials/337](https://www.aliexpress.com/item/rotary-encoders-for-arduino-5pcs/33004406785.html)

Thanks for the suggestions!

felic: If you want 40 buttons, you could get a host usb shield. I mean something like this. Connect an old keyboard to it and define in your code what the keys of this keyboard should do.

Im not sure I understand. Do mean instead of making a button box myself (including bying all the stuff) just using a old keyboard and using this as input? But that would take the fun of designing someting custom out of it...

felic: For the potis, you might be able to simply use rotary encoders instead: [ Rotary encoders run on digital pins and not on analog pins. [/quote]

Again, for clarification: Your suggestion of these rotary encoders would just be in case I would go with the USB shield, right? Or do they have other benefits as well?

felic: Both. https://www.instructables.com/id/Create-a-Joystick-Using-the-Arduino-Joystick-Libra/ https://www.sparkfun.com/tutorials/337

Thanks for the links!](https://www.aliexpress.com/item/rotary-encoders-for-arduino-5pcs/33004406785.html)

I am using an AS6408 64 channel mux with on-board UNO-CORE..

Cuts out a lot of faffing with the muxes.

twinturbo: I am using an AS6408 64 channel mux with on-board UNO-CORE..

Cuts out a lot of faffing with the muxes.

I did a quick reading on the UNO-CORE, is this like a an alternative or arduino or so?

The rotary encoders may simply replace your potis in case you don't have enough analog pins that's all. Rotary encoders have plenty of advantages and disadvantages over potis depending on your needs. I'm sure it's not hard to find the difference between the two with a quick Google search. But to me it sounds like what you would want is more likely a rotary encoder.

They keyboard would already take care of the multiplexing. If you don't like the buttons, no one would keep you from taking out the PCB and simply soldering your own wires to the contacts.

Current is not gonna be an issue with these tiny screens btw. They probably use well under 0.1W. Tip: Look up how much Watt each of your components use (LCDs, Arduino and especially the LEDs) and sum it all up. Divide the result by 5Volt and you get how much current your 5V power supply would have to provide.

Yes, there is a wealth of alternatives to the Arduino "Uno" that all serve different purposes. The UNO-CORE has a very limited number of inputs/outputs but for a data acquisition project can be very attractive when combined with the mux board.

If you need a digital input then just have a high and low analog value and deal with it in code.

TT

felic: The rotary encoders may simply replace your potis in case you don't have enough analog pins that's all. Rotary encoders have plenty of advantages and disadvantages over potis depending on your needs. I'm sure it's not hard to find the difference between the two with a quick Google search. But to me it sounds like what you would want is more likely a rotary encoder.

They keyboard would already take care of the multiplexing. If you don't like the buttons, no one would keep you from taking out the PCB and simply soldering your own wires to the contacts.

Current is not gonna be an issue with these tiny screens btw. They probably use well under 0.1W. Tip: Look up how much Watt each of your components use (LCDs, Arduino and especially the LEDs) and sum it all up. Divide the result by 5Volt and you get how much current your 5V power supply would have to provide.

The rotary encoders look perfect for what I want to do! But I won't be able to use the keyboard idea, as some of the buttons are toggle switches. Additionally, I don't think that the PCB of a complet keyboard would fit into the box I have planned...

Hi everyone,

I was wondering whether there is something special I have to take into account when using toggle switches with an input matrix. Push buttons are transient, but toggle switches are permanently switched on or off. Does that make an input matrix useless? I want to connect a mixture of push and toggle buttons, 30-40 in total.

Background: For simulation games I want to build my own input "button box" that is recognized as joystick in windows. I was planning to use arduino leonardo (not sure yet) and connect both push buttons and mechanical toggle buttons. I will end up with 30-40 inputs from buttons, so I need an input matrix or a multiplexer of some sort. As the arduino has built-in pullup resistors, I wanted to use the pins of arduino (don't know if multiplexers have this functionality, too). But now I am in doubt, whether a toggle button permanently closing or opening one path in the input matrix would render the idea useless...

Any help to my question or a suggestion for a better solution are appreciated! Thanks in advance :-)

It's quite OK, but this is the same requirement as for a keyboard with true "N-key rollover".

You need a diode in series with every switch or button in the matrix.

Paul__B: It's quite OK, but this is the same requirement as for a keyboard with true "N-key rollover".

You need a diode in series with every switch or button in the matrix.

Thanks for the quick reply! Can you maybe suggest a diode that would be suitable? Or maybe tell for what kind of specs I need to look for? I don't have much experience with electronics stuff, I have done more programming so far...

Just out of interest: I found this video on youtube and there, they use toggle switches with a simple input matrix - do you have any idea how they do it? https://www.youtube.com/watch?v=Z7Sc4MJ8RPM (wiring scheme starts at 2:00 mins).

Ah and another thing:

If I have to include diodes, too, soldering and connecting will be much more challenging than I thought. I thought about something like this:

But maybe you know whether there is a PCB that one could buy for what I want to do, maybe even with diodes in it? Someone suggested using a keyboard PCB to me, but that would not fit into the box and it would probably not work with the toggle switches…

Hi, You can use an I2C multiplexer for displays with same ID; Here is a good example of setting one up.

https://www.youtube.com/watch?v=LowMKYcBxNg

Tom... :)

TomGeorge: Hi, You can use an I2C multiplexer for displays with same ID; Here is a good example of setting one up.

https://www.youtube.com/watch?v=LowMKYcBxNg

Tom... :)

Thanks, but this part I have already figured out and that was not part of my question... I know which I2C multiplexer to use for the displays.

My question concerned a multiplexer or matrix for INPUTS of push buttons and toggle switches, since I have planned to use about 40 of them. Sorry if that did not become clear.

The diode is of course, a "general purpose" diode: 1N914/ 1N4148. You can get SMD versions if you are going to make a PCB and there are multi-diode packages, but those are not going to be particularly practical.

Yes, that prototype board that uses the same configuration as a "solderless breadboard" may be useful.

TomRom: Just out of interest: I found this video on YouTube and there, they use toggle switches with a simple input matrix - do you have any idea how they do it?

Yeah, they just wired them up in a matrix, but forgot the diodes, so it will not make sense if switches are left "on" in any single row or column as one button or switch then pressed in the same column or row will appear as being pressed in both corresponding columns or rows.

TomRom: The rotary encoders look perfect for what I want to do! But I won't be able to use the keyboard idea, as some of the buttons are toggle switches. Additionally, I don't think that the PCB of a complet keyboard would fit into the box I have planned...

Okay, first of all there are lots of really small keyboards, if you want a smaller PCB and secondly, as I already said, if you want to use your own switches, just solder them to the PCB directly. It doesn't matter if the switches physically are toggle switches. Just like you could make any normal switch act like a toggle switch in software, you could make a toggle switch act like a normal switch in software.

felic: Okay, first of all there are lots of really small keyboards, if you want a smaller PCB and secondly, as I already said, if you want to use your own switches, just solder them to the PCB directly. It doesn't matter if the switches physically are toggle switches. Just like you could make any normal switch act like a toggle switch in software, you could make a toggle switch act like a normal switch in software.

But wouldn't I need a keyboard with something like an "all key rollover"? Usually, the number of simultaneous button presses is limited on most keyboards to 6 or so. If I switch on 6 or more toggle buttons, wouldn't that be a problem (if I understood it correctly, it is called ghosting or so)

Don't get me wrong: Your idea sounds great and it would save me a low of soldering/wiring, but I am not completely sure that it would work with just any old keyboard...

Instead of a Leonardo you can use a Pro Micro. These use the same chip as Leonardo so can run the same sketches to emulate PC keyboards, but are smaller, cheaper and more practical for building your prototype on breadboard and final soldering onto stripboard or whatever. You can plug Pro Micro directly into breadboard or solder onto stripboard, so no mess of wires between the Arduino and the rest of your circuit.

PaulRB: Instead of a Leonardo you can use a Pro Micro. These use the same chip as Leonardo so can run the same sketches to emulate PC keyboards, but are smaller, cheaper and more practical for building your prototype on breadboard and final soldering onto stripboard or whatever. You can plug Pro Micro directly into breadboard or solder onto stripboard, so no mess of wires between the Arduino and the rest of your circuit.

Good idea. Leonardo has many more I/O pins, however. The pro micro would limit the number of buttons to 36 (6x6 matrix), as there are only 12 I/O pins on it, if I understood it correctly. I have to decide whether 36 is enough...

Pro Micro has 18 pins according to this page. So only 2 fewer than Leonardo.