Wii Nunchuk Mouse Controller- Arduino Uno

4,268

207

5

About: Hi, I'm a student who likes doing random projects! I'm interested in cooking, HTML, and technology. I also love listening to music and downloading millions of PDFS of stuff on here.

Hey guys, CaptainPhysics here, and today, I will be telling you how to take a crappy nunchuk and turn into an awesome mouse for games and other cool stuff. I found this out when I was playing around with the nunchuk and jumper cables and realized how cool to use console stuff on a PC. Anywho, let's get on with the cool beans stuff.

Today, more and more devices are using motion control. From tablets to cellphones to game consoles, people are getting used to interacting with electronics using gestures. Personal computers, however, have lagged behind a bit. Unable to find a suitable gestural controller for my Windows PC on the consumer market, I set out to build my own.

I based my design on the Wii Nunchuk controller for several reasons. First, it’s a versatile, comfortable, well-designed controller; second, it‘s cheap and easy to find; and third, its native I2C serial protocol is easy to interface with Arduino. As a bonus, the connector will accept standard jumper wires, so there’s no need to cut up the cable or use a dedicated adapter. The Arduino runs a sketch that reads data from the controller and prints to the computer’s serial port. The computer runs a Python script, which receives serial data and emulates a mouse.

MATERIALS

Nintendo Wii Nunchuk controller — $17; third-party controllers may not work.

Arduino Uno microcontroller — item #MKSP11 from Maker Shed (makershed.com), $35

140mm male/male jumper wires (4) — item #MKSEEED3 from Maker Shed, $9/65

TOOLS

Windows PC — Mac/Linux users will have to adapt the Python script.

WEB MATERIALS
Download the Arduino IDE for Windows at arduino.cc/en/Main/Software.

Download the ArduinoNunchuk library atgithub.com/GabrielBianconi/ArduinoNunchuk.

Download Python 2.7.2 for Windows at python.org/ftp/python/2.7.2/python-2.7.2.msi.

Download the pyserial module at pypi.python.org/pypi/pyserial.

Download pywin32 at makezine.com/go/pywin32.

Download the Python script at makezine.com/go/nunchuk.

Supplies:

Step 1: Install the Software

The first step is to setup and install the software! This'll be a very important part so make sure you got everything.

Download the Arduino IDE for Windows at arduino.cc/en/Main/Software.

Extract thearduino-1.0 folder to your hard drive. Inside this folder you’ll find arduino.exe.

Download the ArduinoNunchuk library at github.com/GabrielBianconi/ArduinoNunchuk.

Extract the ArduinoNunchuk folder to your hard drive.

Open the Arduino IDE and select File → Preferences.

Note the folder under Sketchbook folder and open it in Windows Explorer. Look for a folder named libraries.

If there isn’t one, you should create it.

Move the ArduinoNunchuk folder into libraries.

Download Python 2.7.2 for Windows at python.org/ftp/python/2.7.2/python-2.7.2.msi and run the installer.

You can find IDLE, the Python IDE, at Start → Python 2.7 or launch it at C:Python27Libidlelibidle.pyw.

NOTE: You should not download Python 3. The script used in this project won’t work with this version.

Download the pyserial module at pypi.python.org/pypi/pyserial.

Extract the pyserial-2.6 folder to C:.

Launch the command prompt window at Start → Accessories → Command Prompt. Type cd /d c:pyserial-2.6 and hit enter.

Now typec:Python27python setup.py install and hit enter again.Download pywin32 at makezine.com/go/pywin32 and run the installer.

The next step is to connect the controller!

Step 2: Connecting the Controller

This is seriously as easy as it gets.

We’ll use 4 colors of jumper wires to simplify the instructions.

Insert the jumpers into the Wii Nunchuk’s connector as shown.

On your Arduino, connect the red wire to +3.3V and the black wire to GND.

Connect the green wire to A5 and the yellow wire to A4.

Remember: Look at the pictures above for reference.

Now we're gonna upload the Arduino sketch!

Step 3: Uploading the Arduino Sketch

Now we will upload the Arduino sketch to the computer and install the drivers!

Connect your Arduino to your computer via USB. If this is the first time, you’ll need to install the required driver. Windows will not be able to install it automatically, so you’ll need to select it in arduino-1.0/drivers.

Open the Windows Control Panel and search for the Device Manager. You can find the port in which your Arduino is inserted under Ports (COM & LPT). Open the Arduino IDE and select the correct port under Tools → Serial Port.

Relaunch Arduino. Select your Arduino model under Tools → Board.

The ArduinoNunchuk library that you’ve installed has an example sketch that prints the data from the Wii Nunchuk to the computer’s serial port. Open the exam-ple file by selecting File → Examples → ArduinoNunchuk → ArduinoNunchukDemo. Upload this sketch to your Arduino.

Open the Serial Monitor. At the bottom right, change 9600 baud to 19200 baud and wait a few seconds. You should see 7 columns of values that change if you move the Wii Nunchuk, move the analog stick, or press a button. If it’s working correctly, close the serial monitor.

Look at the picture above to know where to upload the script.

The final step is to set up the script!

Step 4: Setting Up the Script

Download the Python script at http://cdn.makezine.com/make/2012/11/NunchukMouse_release.py

Open it with IDLE (Right-click → Edit with IDLE).

Look for the line which says port = ‘arduino_port’ and write the correct port (leave the quotes). It should look likeport = ‘COM10’ (use the same port as set up in the Arduino IDE).

Save the script (File → Save or Ctrl+S).Press F5 to run the file and wait a few seconds. Enjoy using the Wii Nunchuk as a computer mouse!

This is CaptainPhysics, signing off.

Share

Recommendations

  • IoT Challenge

    IoT Challenge
  • Fandom Contest

    Fandom Contest
  • Party Challenge

    Party Challenge

5 Discussions

0
None
MohamedM56

3 years ago

I dont have that idle

0
None
MohamedM56

3 years ago

I dont have that idle

0
None
GrinningCheetah

3 years ago

I have a problem with the python code, it doesn't know what ser means

How do I fix it, or what could be going wrong?!

Thank you.

0
None
AndiD7

3 years ago

Great! Ill try it too maybe ill be able too :D

0
None
makeosaurus

3 years ago

Amazing instructable! Didn't know this was even possible!!