Step 8: Adding the Mouse

Picture of Adding the Mouse

Now we will add in the accelerometer to create a tilt-activated mouse. Nearly any accelerometer will do, but the easiest to use is an analog output one. The ADXL335 will work great. First we will power the chip by providing 3.3V (not 5.0V) and ground from the Teensy, then connect the three analog outputs (X Y and Z) to three analog inputs. Finally, we will add Mouse'ing code to the sketch so that Mouse movement events are sent when the controller is tilted.

Cut a piece of ribbon cable down, we'll use Brown for Ground, Red for +3V, then Orange Yellow and Green for X Y and Z respectively [see image 8a].

We tore the brown wire off so that it wouldn't be twisted [see image 8b].

The ADXL335 requires 3V power, so don't connect it to VCC (5V) instead, we'll use the 3V that the teensy provides - it uses that voltage for the USB communication, you can't draw more than maybe 20-40mA which is plenty for this but not enough for perhaps a bunch of LEDs! Brown connects to the second GND pin [see image 8c].

Next connect X, Y, and Z to F5, F4, and F1 (don't use F0!) [see image 8d].

You should now try out the next sketch, teensySNES_test2.pde which will move the mouse as you tilt the controller.