USB Mouse Made Out of a Wii Nunchuck
Intro: USB Mouse Made Out of a Wii Nunchuck
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
Check out the final product in action!
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.
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.
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).
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!
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!
40 Comments
jeffery_is_cool 5 years ago
EmmanuelA110 6 years ago
RobinZ14 7 years ago
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).
TheWaddleWaaddle 12 years ago
-TheWaddleWaaddle
RobinZ14 7 years ago
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);
}
ampu 12 years ago
Thanks for the interest!
RobinZ14 7 years ago
same problem here... cant download code propperly. Maybe post the code as a comment, so we can copy paste it?
TheWaddleWaaddle 12 years ago
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
KevinM486 7 years ago
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!!
Sandisk1duo 12 years ago
ampu 12 years ago
Nickw50 8 years ago
what 'bout chrome os?!?!?!?!
BenjaminK15 7 years ago
The controller mimics a mouse/keyboard.
TricksterG 8 years ago
It should work on a mac.
cndg 8 years ago
It would seem a much better idea to connect the nunchuck using it's existing wires instead of pulling it apart.
Here is how: http://blog.oscarliang.net/wii-nunchuck-arduino-tutorial/
mike.t.dixon 9 years ago
can this be done without chopping up the nunchuck??
Ravirar 10 years ago
is this a mouse as in the joystick is the cursor and the Z/C buttons are right/left click? if so, cool!
juanbajista 10 years ago
haikala 10 years ago
Did you work out any solution to this? I'm trying also to figure out the outputs of the potentiometers...
cdougherty3 10 years ago