Skip to content
Matthew Heironimus edited this page Jun 30, 2020 · 5 revisions

Buttons

How can I connect 32 (or some other large number) of buttons to an Arduino Leonardo or Arduino Micro that only has 13 digital pins and 6 analog/digital pins?

There are various ways this can be done.

I can only see 32 buttons. Can the library support more than 32 buttons?

The library can support more than 32 buttons, however most applications cannot see that many buttons. Different applications use different APIs to read data from the Joystick. The number of buttons supported is typically limited by the API used by the application. For example:

XInput supports maximum of 4 axes, 10 buttons, 2 triggers and 8-direction digital pad per controller, compared to DirectInput's support for 8 axes, 128 buttons, and full-range POV. (The number of axes, buttons and triggers XInput supports corresponds directly to the Xbox 360 controller.)

From https://en.wikipedia.org/wiki/DirectInput

The built-in Windows 10 Joystick test application can only see 32 buttons, even if more than 32 are defined:

Windows 10 Joystick Test Dialog

Pointy's Joystick Test can support up to 128 buttons:

Pointy's Joystick Test

Linux Support

When I plug my Arduino Leonardo or Arduino Micro into a machine running Linux, the joystick does not appear.

or

I only see one joystick when I connect my Arduino Leonardo or Arduino Micro into a machine running Linux, but I have 2 (or more) defined.

To get this to work on Linux, you may need to adjust a setting on the usbhid driver. This can be done by editing the /boot/cmdline.txt file. Add one of the following strings to the end of the line of text in this file (there should only be one line of text in this file):

  • For the Arduino Leonardo
usbhid.quirks=0x2341:0x8036:0x040
  • For the Arduino Micro
usbhid.quirks=0x2341:0x8037:0x040

See the following blog article for more details: http://mheironimus.blogspot.com/2015/09/linux-support-for-arduino-leonardo.html

Thanks go out to @faxm0dem for this question and answer.

Back to Wiki | Back to README

Clone this wiki locally