Use the Button 64 Shield to make a USB Keyboard ?

By | May 21, 2019

The Button 64 Shield is an Arduino shield to which you can connect up to 64 buttons. We had a customer inquiry as to whether or not the Button 64 Shield could be used with an Arduino Leonardo so that it could operate as a standard USB HID to work like a keyboard or game-controller.

SpikenzieLabs Button 64 Arduino Shield

Great question!

Turns out it is super simple. But it would require a few changes to the demo sketch to work with the Leonardo. We started with an Arduino sketch that uses the Button 64 Shield with a serial connection to the host Arduino and modified the code a bit.

The Arduino Leonardo is a bit different than other basic Arduinos. For example the Uno uses an extra IC the ATmega16U2 (and Duemilanova an FTDI chip) to connect to USB. The Leonardo, on the other hand, only has one IC chip (ATmega32u4) that does both the connection to the host computer over USB and running your sketch. The benefits of this is that the Leonardo can appear like a keyboard or mouse to your computer.

Arduino Leonardo

Modifying the basic serial Button 64 Shield demo sketch only required two types of changes.

A. Adding the Arduino keyboard library.

B. Changing the serial commands from; to;

Top: from sketch for Uno. Bottom: shows modification for Leonardo.

Unlike other basic Arduinos where serial pins are shared with the chip doing the USB communications, on the Leonardo the Serial command is for the USB port (think serial monitor) and Serial1 command is used for pins RX-0 and TX-1. Note: all instances of Serial. have to be changed to Serial1. to allow the Button 64 to work with the Leonardo. You can also simply download our demo sketch with the required changes.

More information about the Button 64 Shield can be found on our Learn Pages for the Button 64 Shield.

Leave a Reply