Step 8: 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.
<p>Does the actual version of arduino 1.6.5-r5 works with this hardwere or were i can find the Arduino v18?</p>
I want to do this to a GameCube remote, so how do I connect the analog sticks?
<p>You solder VCC to the VCC pin and the UP,Down left and right to the digital pins, then you open the Arduino IDE and program it using the code that adafruit has on github as something to start with.</p>
Would this work with the Portable Raspberry Pi Emulation Machine (<a href="http://www.instructables.com/id/Portable-Raspberry-Pi-Emulation-Machine/#intro" rel="nofollow">http://www.instructables.com/id/Portable-Raspberry-Pi-Emulation-Machine/#intro</a>)?
OK. I figured this one out. This menu option is no longer there as pictured, but what you should do is to select your teensy board, usually a teensy 2.0 and the go to another sub-menu, also on the Tools menu called, USB Type ... Select Keyboard + Mouse from this menu, and then you can proceed with the rest of these steps.
I have tried to follow these instructions carefully, but I don't see an option for the Teensy (USBKeyboard/Mouse) on my board menu. I do see teensy 2.0 and teensy++(2.0). What is the most likely the cause of that?
why do all this when you can buy a really good quality NEW usb gamepad for $20.<br />
you shut your mouth!!!
Can you actually? I haven't seen a single USB gamepad with a decent D-pad. They all have the horrible design (where it's hard to deliver a 'pure' up/down/right/left because they wobble back and forth between two switches at once) because the good designs are still under nintendo or sony patents.
What would you learn from just buying one?
&nbsp;Its more fun to build than to buy! :)
it is done, because it can be done.&nbsp; It is recycling something&nbsp; that some of us have sitting around in a closet without any use anymore because we dont play Super Nintendo anymore.
=( why aren't you playing your Super Nintendo anymore?&nbsp;It's lonely and it needs love.<br />
Good easy project for people like me that's learning about electronic modification, too. &nbsp; :3<br />
One option if you wanted to do this one the cheap would be to hack the buttons into the inputs of a USB keyboard. Just break open a keyboard and trace out eh leads on the membrane from all of the keys you need, and wire them up directly to the gamepad buttons.<br><br>The big downside is that it would likely involve a care mod to fit the keyboard PCB in with the rest, or I suppose you could run all of the switch leads in a thicker cable to the keybaord PCB in a separate housing.<br><br>Whether or not this is worthwhile is probably a factor of your budget. It'll add some hassle but save $20 for the Teensy.
...This will make playing gameboy games a LOT easier
I think that this would be even better wireless, maybe bluetooth that plugs into the computer on one end, for people who have XBMC computers attached to their TVs.
could you do this with a N64 controller?<br />
Thats what I wanna know too!<br />
Check out http://raphnet.net/electronique/gc_n64_usb/index_en.php
Nice instructable !<br /> <br /> I've done the same thing some time ago with a &quot;full&quot;&nbsp;DIY&nbsp;version :<br /> <br /> You have 2 possibilities&nbsp;:<br /> <br /> 1 -<a href="http://raphnet.net/electronique/snes_nes_usb/index_en.php" rel="nofollow"> raphnet.net/electronique/snes_nes_usb/index_en.php</a><br /> he use an atmega 8 with a xtal for the pad-usb conversion. It's a nice idea, but the overall size of the project (if you do it without a PCB) is a tad big to fit inside the pad.<br /> <br /> 2 - <a rel="nofollow">translate.google.ca/translate</a><br /> He use a small Attiny 45 with internal osc for the pad-usb conversion. I've used this method for my own pad. It fit quite easily in a SNES&nbsp;gamepad. I didn't have any Attiny45 on hand, but I had some Attiny25... I've managed to make the code smaller and include the auto usb calibration. It was quite a tight fit in the 2k memory!&nbsp; I'll try to post my modified files for you to enjoy.<br /> <br /> I might even post an instructable if I have some spare time.<br /> <br />
Here's the second link :<br /> <br /> http://translate.google.ca/translate?hl=fr&amp;langpair=de|en&amp;u=http://hobbyelektronik.org/w/index.php/SNES-Joypad<br /> <br />
Hi, cheers for an excellent Instructable. Was wondering, can this be easily applied to a Sega Mega Drive 6 button gamepad?<br />
Looks great! I'll have to try this some time.<br />
&nbsp;Thanks! &nbsp;Always enjoy your tutorials.

About This Instructable


150 favorites


Bio: All-original DIY electronics kits - Adafruit Industries is a New York City based company that sells kits and parts for original, open source hardware electronics projects ... More »
More by adafruit: Adaruit Resistor Helper Adafruit Photo Tutorial Logger Shield: Datalogging for Arduino
Add instructable to: