From Trammell Hudson's Projects
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:
The code flashed on the devices is in github/osresearch/trinket 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: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
Install the Trinket Keyboard/Mouse library: https://github.com/adafruit/Adafruit-Trinket-USB/archive/master.zip 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.