I am building a flight sim button box and I would like someone to please check my proposed wiring diagram.

I will be using 12 buttons, 4 rotary encoders, each also with a push button and 4 (on)-off-(on) toggle switches as well as one additional toggle switch to use as a modifier for the buttons.


Any comments or suggestions appreciated.

  • 1
    It won't work. Lines 4-7 are shorted through line 9. Matrix works with buttons (mostly) - if you press more buttons, it can create false pressed button (press 7-13, 6-13, 6-12 and 7-12 will be detected as pressed too). Only way is using diodes for each button and switch – KIIV Aug 27 '20 at 15:26
  • 1
    @KIIV good catch. I think only adding diodes to the switches will already help a lot. Pressing 3 buttons is less likely than toggling two switches and pressing one button. – Gerben Aug 27 '20 at 15:45
  • that is a 5x6 button matrix ... arduino.stackexchange.com/questions/50869/… .... the four rotary encoder buttons and the toggle switch at the bottom would make the 5th column – jsotola Aug 27 '20 at 16:56
  • the rotary encoders could also be part of the matrix ... it depends on the encoder type and on how you intend to use the encoders – jsotola Aug 27 '20 at 17:38
  • I see that the drawing makes it look like there is a short between 4-7 and 9, that is meant to be a jump over. I have decided to just add the diodes, they are quite easy to add and I have 50 at hand so no big issue. – Nc Bean Aug 28 '20 at 6:32

Pins 0 and 1 are used for serial, which could make it harder for debugging.

Unless you use triple throw switch, you don't need both 9 and 8. Not reading a switch closed on 9, means it has to be closed on 8.

I'd swap 0 and A0, so the third rotary encoder has its pins from the same pin-register.

I'd maybe add resistors, so that if I accidentally define a pin as OUTPUT, I don't get a dead short when a button is pressed.

Depending on how many buttons you allow to be pressed at the same time, you might have to add diodes to the buttons to prevent n-key rollover.

  • and 4 (on)-off-(on) toggle switches ... – Majenko Aug 27 '20 at 15:19
  • @Majenko oops! Missed that one. – Gerben Aug 27 '20 at 15:34
  • I had to look twice to see it too ;) – Majenko Aug 27 '20 at 15:34
  • Thank you for having a look, I will be adding diodes to the system, will give feedback once I have started soldering :) – Nc Bean Aug 28 '20 at 6:35

Edited to suggest driving the outputs low.

To use a multiplexed grid of switches like that you'll need to write code that sets all the columns to open, sets all the input rows to INPUT_PULLUP, drives one column at a time low and scans the rows for low output to figure out which buttons are pressed. (You could reverse the rows and columns, or add external pull down resistors and pull the rows/columns high rather than grounding them, but you get the idea. You'll need to write code to scan the grid of buttons in nested for loops.)

  • You need to drive the columns LOW (one at a time), and have pull-up resistors enabled on the rows. If you want to drive them HIGH, you need (external) pull-down resistors on the rows. – Gerben Aug 27 '20 at 15:33
  • 1
    Just use the Keypad.h library like everyone else... – Majenko Aug 27 '20 at 15:35
  • @Gerben yeah, either drive them low and run the inputs in INPUT_PULLUP mode, or drive them low and add external pull-down resistors. The schematic doesn't show pullup or pull-down resistors, so it would be better to drive the columns low. – Duncan C Aug 27 '20 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.