Brand new Wii Nunchuck library for Arduino 1.0

Hey everyone,
While checking out the old “wiichuck demo” code online, I realized that it was based on Arduino 0010, pretty outdated! But I came across a brand new library, released the 20th!
The library was made by Gabriel Bianconi, not me. I tried it out and it works very well from what I’ve tested so far. It’s a great way to set up a Nunchuk quickly, almost “plug and play”. Wrote up a quick code to show activity through a row of LED’s… haven’t got it all commented yet, but it’s relatively harmless. :slight_smile:

#include <Wire.h>
#include "ArduinoNunchuk.h"

ArduinoNunchuk nunchuk = ArduinoNunchuk();

int xjoystick;
int yjoystick;
int xtilt;
int ytilt;

void setup() {
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT);


void loop(){  
  if(nunchuk.cButton == 1 && nunchuk.zButton != 1){
    digitalWrite(12, HIGH);
    digitalWrite(12, LOW);
  if(nunchuk.zButton == 1 && nunchuk.cButton != 1){
    digitalWrite(11, HIGH);
    digitalWrite(11, LOW);
  if(nunchuk.cButton == 1 && nunchuk.zButton == 1){
    digitalWrite(10, HIGH);
    digitalWrite(10, LOW);

  xjoystick = nunchuk.analogX;
  xjoystick = constrain(xjoystick, 26, 226);
  xjoystick = map(xjoystick, 26, 226, 0, 255);
  analogWrite(9, xjoystick);

  yjoystick = nunchuk.analogY;
  yjoystick = constrain(yjoystick, 26, 226);
  yjoystick = map(yjoystick, 26, 226, 0, 255);
  analogWrite(6, yjoystick);

  xtilt = nunchuk.accelX;
  xtilt = constrain(xtilt, 320, 720);
  xtilt = map(xtilt, 320, 720, 0, 255);
  analogWrite(5, xtilt);
  ytilt = nunchuk.accelY;
  ytilt = constrain(ytilt, 320, 720);
  ytilt = map(ytilt, 320, 720, 0, 255);
  analogWrite(3, ytilt);

Have fun!

Hey Alex, thanks for sharing my library! XD

I will use this library to connect my nunchuck! Seems really simple and clean, thanks!

Mhn maybe I can shot a question :smiley:

Do you know any software that takes these serial input from the nunchuck(via Arduino) and recognize them as a HID joystick or something similar?
I just want to you is as a joystick for mame/vice emulators…

Worked like a charm! Thanks! :D

I’m trying to get this working and I’ve hooked the data pin to A4, clock pin to A5 (per the wire library instructions, I have an Uno), pwr pin to arduino 3.3 v and ground to arduino ground, however when I hook any two of the pins up, the serial monitor freezes. As soon as I disconnect the wires, the serial monitor resumes updating. I tried resetting the Uno with the serial monitor open and stuff plugged in, but still no luck. Any ideas?

Nevermind--I'm an idiot... Instead of the wire being plugged into the 3.3V header pin, it was plugged into the reset pin which happens to be right next to it...Works great now. Thanks for the library.

this ArduinoNunchuk.h sketch is no longer there the link is dead. Can someone please post the sketches in zip format?

Dead Link :-(

Here you can find a derivation of a new library: and the source can be found here: