USB Mouse Made Out of a Wii Nunchuck

59,312

274

41

Posted

Introduction: USB Mouse Made Out of a Wii Nunchuck

USB Contest

Finalist in the
USB Contest

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!
http://www.youtube.com/watch?v=YBNEImY_uzQ

Step 1: Materials

This is what you'll need:

Components:
-  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!


Share

    Recommendations

    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Space Challenge

      Space Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    40 Comments

    Is it possible to make something similar with wii guitar hero drums? The cable is so similar to nunchuk

    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).

    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.

    -TheWaddleWaaddle

    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:

    signed int xanal;

    signed int yanal;

    int mouse_l;

    int mouse_r;

    unsigned int i = 0;

    #define x_t_low 190

    #define x_db_low 480

    #define x_ctr 123

    #define x_db_hi 505

    #define x_t_hi 772

    #define y_t_low 222

    #define y_db_low 520

    #define y_ctr 133

    #define y_db_hi 550

    #define y_t_hi 831

    void setup() {

    pinMode(8,INPUT_PULLUP);

    pinMode(7,INPUT_PULLUP);

    }

    void loop() {

    signed int xmove = 0;

    signed int ymove = 0;

    xanal=analogRead(0);

    yanal=analogRead(2);

    // linear - low speed

    if (xanal < x_db_low && xanal > x_t_low || xanal > x_db_hi && xanal < x_t_hi) {

    xmove = ((xanal / 4) - x_ctr)/18;

    }

    if (yanal < y_db_low && yanal > y_t_low || yanal > y_db_hi && xanal < x_t_hi) {

    ymove = (-1*((yanal / 4) - y_ctr))/18;

    }

    // linear - turbo

    if (xanal < x_t_low || xanal > x_t_hi) {

    xmove = ((xanal / 4) - x_ctr)/12;

    }

    if (yanal < y_t_low || yanal > y_t_hi) {

    ymove = (-1*((yanal / 4) - y_ctr))/12;

    }

    Mouse.move(xmove,ymove);

    // click and drag

    // right click

    if(digitalRead(7) == HIGH)

    { if(digitalRead(7) == LOW)

    {

    mouse_r = 1;

    } else {

    mouse_r = 0;

    }

    } else {

    mouse_r = 1;

    }

    // left click

    if(digitalRead(8) == HIGH)

    { if(digitalRead(8) == LOW)

    {

    mouse_l = 1;

    } else {

    mouse_l = 0;

    }

    } else {

    mouse_l = 1;

    }

    Mouse.set_buttons(mouse_r, 0, mouse_l);

    }

    user

    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.

    Thanks for the interest!

    same problem here... cant download code propperly. Maybe post the code as a comment, so we can copy paste it?

    ampu,
    I downloaded a different browser to see if it was my browser, but whenever I download it, it turns from "teensy_mouse_clean.pde" to "F0T0YIKGQ5Q49T.tmp", 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!

    -TheWaddleWaddle

    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!!

    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?

    user

    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!