Very simple button box

I am a complete beginner and I am trying to make a simple button box matrix with 2 rows and 7 columns for use as a "game controller" in windows.

I am unable to find a sketch example with just a button matrix, they all have rotary encoders and such.

Looking at the sketch I have, I don't know what parts of the code pertain to the rotaries and what parts are just for the button matrix. If I take out the parts of the code that look like they are for the rotaries, it breaks the rest of the code.

I am just looking for a resource on how to code the button matrix and use joystick.h or keypad.h to make it show up as a "game controller" so I can assign the buttons.

Any information or start point so I can learn just what I need for the button matrix and keypad.h/joystick.h integration.

On the arduino.cc website you could find an example for how to use the keypad.h library.

You just need to change the names of the buttons, the pin number of the collumns and rows and then you can read a button HIGH or LOW signal with an if loop.

If you want to control your pc with the buttons you can include the keyboard.h library to press any key you want with the arduino.

1 Like

Forward a sketch to see how.

Hi @oscarley,

there are examples on the internet which you can directly try on Wokwi:

ButtonMatrix 20x without diodes (which I created for a different thread here):

and these basic Wokwi examples:

Keypad programming

Analog joystick

which might bring you forward ...

Be aware that the simple button matrix as also the keypad are not designed for multiple buttons pressed simultaneously! If you need to identify parallel button presses in a matrix you will need to add diodes to avoid "ghosting" ...

See e.g. here https://www.baldengineer.com/arduino-keyboard-matrix-tutorial.html

Good luck!

1 Like

This is brilliant, I am blown away by the help I'm getting. Thanks guys!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.