This instructable will describe how to convert a Nintendo Wii Nunchuck controller into a USB 2-button mouse using a Teensy USB.  The Teensy USB is a very user-friendly development board that can be programmed in an Arduino environment. The Teensy USB development board and necessary software are available at www.pjrc.com

Check out the final product in action!

Step 1: Materials

This is what you'll need:

-  Nintendo Wii Nunchuck Controller, available at various retailers
-  Teensy 2.0 USB Development Board, available at www.pjrc.com
-  USB cable, available at www.pjrc.com
-  Breadboard (for prototyping), available at www.sparkfun.com
-  22 Gauge Wire, available at www.sparkfun.com
-  Solder, available at www.sparkfun.com

Aside from the components listed above, you should have access to various tools such as a soldering iron and ancillary hand tools. Additionally, you should have basic soldering skill and working knowledge of the Arduino environment before embarking on this journey. 

Step 2: Nunchuck Disassembly

Remove the two screws on the underside of the Nunchuck controller using a tri-wing screwdriver and un-clip the top shell of the Nunchuck to expose the electronics.

Remove the electronics and un-clip the two hooks of the white molded plastic part at the center to access the electrical connectors of the x and y-axis potentiometers.

Remove the flexible membrane to access the electrical connectors of the C and Z buttons. The middle connection (red wire) is the Z button and top connection (black wire) is the C button.

Step 3: Prototyping on Breadboard

As good practice you should always prototype your project on a breadboard. The Teensy 2.0 comes with optional header pins making prototyping a breeze. Connect the Teensy controller to the inputs of the Nunchuck controller in the following manner:

Teensy              Nunchuck
GND                  Ground (each potentiometer and buttons)
+5V                    5 Volts (each potentiometer)
F0                      X-axis potentiometer output
F4                      Y-axis potentiometer output
D2                     C button
D3                     Z button

Once you've connected everything per the table above, you're ready to program. In addition to putting the attached code into the Arduino window, make sure the settings are correct for this project. The board should be identified as "Teensy 2.0" and the USB Type "Keyboard + Mouse".

Upload the code and press the reset button on the Teensy. Play around with the joystick and both buttons to confirm everything is working the way it should. A simple mistake would be to mix up the X and Y directions or the C and Z buttons, but that can be easily fixed by swapping the connections on the breadboard (another good reason you should always prototype everything).

Step 4: Final Assembly

Once you have the code right on the Teensy it's time to prepare all the components for final assembly.

Nunchuck shell modifications
- Trim both halves of the shell as detailed in the pictures to make room for the additional hardware

Electronics modifications
- Using a soldering iron, remove all header pins from Teensy board
- Trim and strip all wires coming from the Nunchuck electronics and solder them directly into the Teensy board. You're working with in  snug quarters so make sure you make your assembly nice and tight.

After those simple modifications have completed the electronics should fit right into the lower half of the shell. Once the electronics are in, all you need to do is snap the halves back together and install the screw into the remaining screw hole. Plug it in and enjoy!

<p>Im making my own wii nunchuck mouse, but swapped the joystick for 1 with a button in it. I had some trouble hooking up the C and Z buttons, and found out you apparently made a mistake. The black wire goes to ground, the red and white wire are for the C and Z buttons (use INPUT_PULLUP).</p>
I am having troubles with viewing the code. Everytime I click on it it turns into a random jumble of HTML. Does anyone know why this is happening? I have the Arduino IDE, so that's not a problem.<br><br>-TheWaddleWaaddle
<p>After some trying i decided to download the code, but chose file type as 'all types', and added .pde after the file name (making it a .pde file). After that i opend the file in Code::Blocks and...tada! the code! (I hope) Im gonna test it after hooking it all up, but it seems to be it :D Heres the code:</p><p>signed int xanal;</p><p>signed int yanal;</p><p>int mouse_l;</p><p>int mouse_r;</p><p>unsigned int i = 0;</p><p>#define x_t_low 190</p><p>#define x_db_low 480</p><p>#define x_ctr 123</p><p>#define x_db_hi 505</p><p>#define x_t_hi 772</p><p>#define y_t_low 222</p><p>#define y_db_low 520</p><p>#define y_ctr 133</p><p>#define y_db_hi 550</p><p>#define y_t_hi 831</p><p>void setup() {</p><p> pinMode(8,INPUT_PULLUP);</p><p> pinMode(7,INPUT_PULLUP);</p><p>}</p><p>void loop() {</p><p> signed int xmove = 0;</p><p> signed int ymove = 0;</p><p> xanal=analogRead(0);</p><p> yanal=analogRead(2);</p><p>// linear - low speed</p><p> if (xanal &lt; x_db_low &amp;&amp; xanal &gt; x_t_low || xanal &gt; x_db_hi &amp;&amp; xanal &lt; x_t_hi) {</p><p> xmove = ((xanal / 4) - x_ctr)/18;</p><p> }</p><p> if (yanal &lt; y_db_low &amp;&amp; yanal &gt; y_t_low || yanal &gt; y_db_hi &amp;&amp; xanal &lt; x_t_hi) {</p><p> ymove = (-1*((yanal / 4) - y_ctr))/18;</p><p> }</p><p>// linear - turbo</p><p> if (xanal &lt; x_t_low || xanal &gt; x_t_hi) {</p><p> xmove = ((xanal / 4) - x_ctr)/12;</p><p> }</p><p> if (yanal &lt; y_t_low || yanal &gt; y_t_hi) {</p><p> ymove = (-1*((yanal / 4) - y_ctr))/12; </p><p> }</p><p> Mouse.move(xmove,ymove);</p><p>// click and drag</p><p> // right click</p><p> if(digitalRead(7) == HIGH)</p><p> { if(digitalRead(7) == LOW)</p><p> {</p><p> mouse_r = 1;</p><p> } else {</p><p> mouse_r = 0;</p><p> }</p><p> } else {</p><p> mouse_r = 1;</p><p> } </p><p> // left click</p><p> if(digitalRead(8) == HIGH)</p><p> { if(digitalRead(8) == LOW)</p><p> {</p><p> mouse_l = 1;</p><p> } else {</p><p> mouse_l = 0;</p><p> }</p><p> } else {</p><p> mouse_l = 1;</p><p> } </p><p> Mouse.set_buttons(mouse_r, 0, mouse_l);</p><p>}</p>
I just tried and it worked fine for me, maybe the instructables site was acting funny when you first tried it. Please let me know if you have any other issues, if need be I'll be happy to email it to you directly.<br><br>Thanks for the interest!
<p>same problem here... cant download code propperly. Maybe post the code as a comment, so we can copy paste it?</p>
ampu,<br>I downloaded a different browser to see if it was my browser, but whenever I download it, it turns from &quot;teensy_mouse_clean.pde&quot; to &quot;F0T0YIKGQ5Q49T.tmp&quot;, which the Arduino IDE continually refuses to open. I tried converting it to a .pde file, but none of my attempts worked. If you could, could you please email it to me directly? God bless you for your help!<br><br>-TheWaddleWaddle
<p>Fantastic project! Could you please include a photo showing how the wires connect to the nunchuck pcbs? You cannot see that at all in your photos. THNX!!</p>
Would this work for all computers? What i mean is, if you plug the usb plug into another computer without any software, would it run like a regular mouse? I guess what i'm asking is, do you need pre-installed software to be able to use the mouse?
There is no software required. The controller mimics a mouse/keyboard, so it'll work on any PC, not sure about macs. Thanks for your interest!
<p>what 'bout chrome os?!?!?!?!</p>
<p>The controller mimics a mouse/keyboard.</p>
<p>It should work on a mac.</p>
<p>It would seem a much better idea to connect the nunchuck using it's existing wires instead of pulling it apart.</p><p>Here is how: http://blog.oscarliang.net/wii-nunchuck-arduino-tutorial/</p>
Is it work with teensy 3.1.
<p>can this be done without chopping up the nunchuck??</p>
<p>is this a mouse as in the joystick is the cursor and the Z/C buttons are right/left click? if so, cool!</p>
Please provide details for where the ground, 5v, and output of each potentiometer is located. It looks like you have some wires that run up underneath the analog stick that aren't in the &quot;pre-instructables&quot; nunchuck...
<p>Did you work out any solution to this? I'm trying also to figure out the outputs of the potentiometers...</p>
I'm having a hard time figuring out which wires inside the nunchuck correspond to the buttons/joystick. Could you post some sort of color chart or some other explanation.
I am having trouble downloading the code, could you possibly email it to me, also how would I go about programming a third button to use as a scroll button, like when you click the scroll wheel on a mouse, thanks
I am having trouble downloading the code. I have the same problem as TheWaddleWaaddle does. I am downloading it as a .tmp file instead of a .pde file. I NEED HELP PLEASE :(
could you use a old computer mouse chip and re solder the wires to the controller wires instead of buying the programing chip?
Hi,<br><br>je parle que le fran&ccedil;ais, je sui tr&egrave;s int&eacute;ress&eacute; par ton nunchuck.<br><br>Je voudrais t'en acht&eacute; un peut tu m'en faire un je te paie d'avance.<br><br>merci de me r&eacute;pondre j'attend avec impatience best regard
I'm having trouble figuring out some of the connections, the picture of your breadboard shows 6 wires, going by the directions and my sparse knowledge I end up with 9. I understand the center pin for each POT and the connections for the C and Z buttons, but the voltage and ground are where I'm off. From what I can glean from wiired.org and your pictures 3 of your connections go to the 3rd pin(yellow/clock wire) on the nunchuck, I can't figure out what they are or what they are for. I have a connection from each POT's left pin to the voltage, and a connection from each POT's right pin to the ground, all from the point of view of looking at the bottom side(chip side). So, I guess my question is: Am I supposed to use the linear pin connections? Also, can I just connect Tweeny's voltage and ground to the pin 1(red) and pin 5(white) respectively?
Hey dude I think the idea is great because I have a muscular syndrome that makes holding my arm up at a desk really painful over a period of time. I currently use a thumball mouse but they are hard to come by on the shelf and I'd like to give this a go for comfort.<br><br>I haven't got your skills, knowledge and talents I was wondering if I could buy a working model off you? If I can can I use a really groovy nunchuck as the base or do the covers come separate? I'm in my 40's now so a little old to know about the latest gaming platforms as I havent had them due to my condition but this may open my world to a lot of other gaming capabilities through the PC. I would especially like to try a first person shooter but using arrow keys etc has been a really bad experience for me.<br><br>Thanks for any feedback dude!<br>
Also does anyone know of a scroll ball type nunchuck?
You could program a macro that when you pressed the second button on the nunchuck and moved the thumbstick it would be like a scroll wheel.
what did you do about the accelerometer in the NunChuck.
I chose not to use it. We had a &quot;presentation mouse&quot; at a previous job that used accelerometers to point, but it was very shaky and didn't have enough accuracy to be useful.<br><br>However, as I understand it, the accelerometers output analog data just like the potentiometers so it would be very difficult to add them for a scrolling function or something else all together. The only tricky part would be to find where the accelerometer outputs are located on the nunchuck circuit board.
i hear 30 seconds to mars - this is war at the background &lt;3
Good ear!
Use one of those wireless Nunchuks. I know you used the potentiometer readings directly, but you can also communicate with the Nunchuk via I2C, which would solve this problem, allowing you to use wireless Nunchuks.<br><br>In your code, you seem to have defined center analog values as constants. Although it works, I'm not sure if the same values would work for everybody. If anybody attempts this project and experiences the mouse cursor slowly &quot;drifting&quot;, you would need to make changes to those constants.<br><br>This may become a major issue as the Nunchuk becomes older, wear and tear might prevent the joystick from returning to the true center position. Or some &quot;play&quot; might develop in the joystick mechanism.<br><br>One technique to solve the above problem is to take one reading upon power-up, making sure that you let go of the joystick during power-up. Use that initial reading as the center reading instead. This technique is essentially re-calibrating the center value upon every power-up<br><br>Another technique is to simply implement a &quot;dead zone&quot; in the center such that if the joystick is anywhere within this &quot;dead zone&quot;, then you don't actually move the mouse cursor. This technique is implemented inside the Wii Classic Controller's firmware (at least in my knockoff version) and my MadCatz PS2 controller.
Excellent observations! I set up the constants and dead band values based on what my nunchuck was outputting. I wrote a simple program that outputted the potentiometer readings to a serial output window using the &quot;serial.print&quot; function. Once I saw the neutral values and how they bounce around (3-4 points above or below), I inputted those values into the constants of the main program. <br><br>I'll upload that code shortly. Anyone interested in trying to make one can do this quick check during the breadboards prototyping step.<br><br>As for the reading the potentiometer value at start-up. That is a good idea, I'll look into it. Thanks for the input!
Wait... the TeensyUSB <strong>can act as a USB mouse or keyboard</strong>?&nbsp;Just to clarify, do I need Processing or something running on my computer for this to work? To put it another way, could you plug your Nunchuck-mouse into a computer without any of the Teensy software on it and it would still work?<br> <br> <em>nerd-potential-gasm</em><br> <br> This is the missing piece for a project I've been wanting to do (well, do properly) for so long... I'm going to have to get one. &nbsp;
Yes, I can plug in my nunchuck mouse into any computer and it'll work. The Teensy works as a mouse or keyboard if you set it up to do so. Check out www.pjrc.com/teensy/td_mouse.html <br><br>The Teensy software is only needed to program it.
this is nice but i am not good at hacking things so i use a program called joy to key. ( http://joytokey.webs.com/download.htm )<br>you can do almost everything with it.
Does this software have the capability to make it a joystick?
could you detail the steps has welded or simplify the sch&eacute;ma<br><br>very nice idea
Very nice...I'm highly tempted to try this right now. Nicely written 'ible, too. Kudos!

About This Instructable




More by ampu:USB Mouse Made Out Of A Wii Nunchuck 
Add instructable to: