Skip to content


Trinket USB Accellerometer Keyboard

This project combines an Adafruit Trinket with a i2c accelerometer to create a USB seismograph. The output is sent as the keys A to Z to make it easy to integrate with environments like Scratch.


The header pins need to be cut to the right length for the Trinket. The breadboard can be used as a jig to hold the pins straight on the Trinket. For the accelerometer it helps to put another header underneath to hold it level.

We held a soldering party to put together forty kits. So many header pins!


The two components can be connected on the breadboard or in the air using female-female jumper wires. Don't connect them while the Trinket is powered to avoid accidental shorts or other problems! The pinout is:

Function Trinket MMA8451 Color
Power USB VIN Red
Ground GND GND Black
Data #0 SDA Yellow
Clock #2 SCL Green


The code flashed on the devices is in in the imu/ directory. If you want to change the update rate it is controlled by the last_keystroke timeout in loop().

To setup the Arduino IDE you need to install the Adafruit board package. In Preferences, add to the Board Manager URL:

Install the Trinket Keyboard/Mouse library: or go into Library Manager and install Trinket Keyboard


Adafruit MMA8451 library was too big to fit along with the keyboard library, so I cut it down to just the pieces that were required. The driver is included in the source tree above.

2016 AVR Arduino

Last update: November 8, 2020