Posted on 21 Comments

How To Program The Pro Micro (atmega32u4) As A USB Gamepad Controller With Arduino

This tutorial should work on any Arduino Leonardo compatible board like the Sparkfun Pro Micro and the most popular Arduino Pro Micro compatible board. They’re all the same.

Let’s Get Started (Microsoft Windows):

    1. First, download and install the latest Arduino IDE at
    2. Run the software, create a new file, copy and paste the code from
    3. Now let’s install the Arduino Joystick Library. Download the library. On Arduino IDE, click on Sketch > Include Library > Add .ZIP Library…, browse to the zip file you downloaded and click Open. A message should appear at the bottom telling you that “Library added to your libraries. Check “Include library” menu“.
    4. Plugin in the Pro Micro with a micro usb data cable and let Windows install the device. Take note of the COM port number used by the device (COM9 in this example).
    5. Now on Arduino IDE, click on Tools > Board > Arduino Leonardo.
    6. Click on Tools again, choose Port and the port used by your Pro Micro.
    7. Finally, click the Upload button or press CTR + U to flash/program the Pro Micro. You should see “Done uploading.” at the bottom if it’s successful.

Here’s how to enable Analog Stick support.

Comment below if this tutorial works for you or not.

Products you might be interested with:

21 thoughts on “How To Program The Pro Micro (atmega32u4) As A USB Gamepad Controller With Arduino

  1. Programmed my Pro Micro I bought from EBay with the code above and it works great. Thank you!

  2. Thank you! Great tutorial!

  3. This is what Im getting….

    Arduino: 1.8.4 (Windows 7), Board: “Arduino/Genuino Uno”

    C:\Users\hp\Documents\Arduino\sketch_apr04c\sketch_apr04c.ino:6:22: fatal error: Joystick.h: No such file or directory



    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    1. Manually adding the library should do it.

  4. I think they must’ve changed the file structure. I couldn’t add it as a .zip file, because it kept saying it didn’t contain a valid library. But if you unzip it and read the file, it says to copy the Joystick folder to the Arduino\libraries folder (under My Documents). Then when you restart Arduino it sees it as a library and the sketch compiles.

  5. soon as i got my self a propper data cable it worked a charm. Thanks love the boards 🙂

  6. […] Here’s How to Program the Pro Micro with Arduino. […]

  7. Thank you, You saved me a lot of messing around with other code i have found.

    Leonardo Pro micro working as expected.

    One question. Do i need to setup the dpad in any special way or just connect each direction to a free pin?

    I have no need for analogue with my current setup.

    Do I possibly need to modify the joystick.h file ?
    #5 = gamepad.

    1. Just connect the buttons to the pins that were used at the code. Check the pinout guide for pro micro at

      Analog stick is disabled by default.

  8. By adding a micro-controller you eliminate the need to hard wire the controller board to the Pi unit right? So the Pi will see a USB type controller rather than needing to add the retrogame port for GPIO control? Also, can I use a Teensy LC to run this software?

    1. Yes that’s correct.

  9. For those getting leonardo board errors:

    I was having trouble with the Arduino writing to my Pro-Micro because the most recent leonardo drivers (1.6.23 newest as of Jan 2019) weren’t compatible with the code or something, so what i did was go back to a previous version, 1.6.22, and it seemed to like that and wrote just fine.

    maybe give that a try if youre having some troubles.

  10. Pretty good info but the screen shots of the setup menus kinda got in the way. Also – where is it explained for the Joystick Library how to set up pins and button numbers. I pawed thru the original code and .h file and see no indication how to actually USE the library. Not comment one in it! Your code get closer but still leaves a lot of questions on how to MAKE MY OWN and no copy yours.

  11. Hello,

    Will this code work on a Xbox Adaptive Controller?

    Kind regards,

  12. why i canot press more than 1 button at the time?

    1. Hi you need to add diodes to your circuit to eliminate ghosting (its what is called when you pre like 3 buttons and more in the same row or column light up) you wired using a matrix correct?

  13. this works on Windows Testing
    but i cant map Emulation station via USB (atmega32u4 controller)…

    any ideas?

  14. I have a couple of button boxes that i built and all work great, i have an idea for a new one. What code would i add to the sketch for a hat switch and how would the wiring be? I am actually just going to use the HAT function as extra buttons if that is possible because the limit in some games are 32 buttons for gamepads. Then how would one code an LED to light up if button 8 for example is pressed on the joystick?

  15. Hello, can you make a fighting stick with 10 buttons and hat switches? for ardunio pro micro

  16. Doesn’t work

    Connecting to programmer: .
    Found programmer: Id = “CATERIN”; type = S
    Software Version = 1.0; No Hardware Version given.
    Programmer supports auto addr increment.
    Programmer supports buffered memory access with buffersize=128 bytes.

    Programmer supports the following devices:
    Device code: 0x44

  17. After hours of trying I found this and thought ‘Why not. Nothing to lose. It probably won’t work’
    It worked. Into XP12 and there it is!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.