├── ArduinoNunchuk ├── keywords.txt ├── ArduinoNunchuk.h ├── examples │ └── ArduinoNunchukDemo │ │ └── ArduinoNunchukDemo.ino └── ArduinoNunchuk.cpp ├── README.md └── LICENSE.md /ArduinoNunchuk/keywords.txt: -------------------------------------------------------------------------------- 1 | ArduinoNunchuk KEYWORD1 2 | init KEYWORD2 3 | update KEYWORD2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **NOTE:** This project is no longer maintained (but should be functional). 💀 2 | 3 | # ArduinoNunchuk 4 | 5 | ## Introduction 6 | 7 | Improved Wii Nunchuk library for Arduino 8 | 9 | Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/ 10 | 11 | Based on the following resources: 12 | - http://www.windmeadow.com/node/42 13 | - http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ 14 | - http://wiibrew.org/wiki/Wiimote/Extension_Controllers 15 | 16 | ## Installation 17 | 18 | Copy the 'ArduinoNunchuk' folder, located in the same folder as this 'README' file, to the Arduino libraries folder (Arduino/libraries). 19 | -------------------------------------------------------------------------------- /ArduinoNunchuk/ArduinoNunchuk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ArduinoNunchuk.h - Improved Wii Nunchuk library for Arduino 3 | * 4 | * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/ 5 | * 6 | * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/ 7 | * 8 | * Based on the following resources: 9 | * http://www.windmeadow.com/node/42 10 | * http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ 11 | * http://wiibrew.org/wiki/Wiimote/Extension_Controllers 12 | * 13 | */ 14 | 15 | #ifndef ArduinoNunchuk_H 16 | #define ArduinoNunchuk_H 17 | 18 | #include 19 | 20 | class ArduinoNunchuk 21 | { 22 | public: 23 | int analogX; 24 | int analogY; 25 | int accelX; 26 | int accelY; 27 | int accelZ; 28 | int zButton; 29 | int cButton; 30 | 31 | void init(); 32 | void update(); 33 | 34 | private: 35 | void _sendByte(byte data, byte location); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /ArduinoNunchuk/examples/ArduinoNunchukDemo/ArduinoNunchukDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ArduinoNunchukDemo.ino 3 | * 4 | * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/ 5 | * 6 | * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/ 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #define BAUDRATE 19200 14 | 15 | ArduinoNunchuk nunchuk = ArduinoNunchuk(); 16 | 17 | void setup() 18 | { 19 | Serial.begin(BAUDRATE); 20 | nunchuk.init(); 21 | } 22 | 23 | void loop() 24 | { 25 | nunchuk.update(); 26 | 27 | Serial.print(nunchuk.analogX, DEC); 28 | Serial.print(' '); 29 | Serial.print(nunchuk.analogY, DEC); 30 | Serial.print(' '); 31 | Serial.print(nunchuk.accelX, DEC); 32 | Serial.print(' '); 33 | Serial.print(nunchuk.accelY, DEC); 34 | Serial.print(' '); 35 | Serial.print(nunchuk.accelZ, DEC); 36 | Serial.print(' '); 37 | Serial.print(nunchuk.zButton, DEC); 38 | Serial.print(' '); 39 | Serial.println(nunchuk.cButton, DEC); 40 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Gabriel Bianconi 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /ArduinoNunchuk/ArduinoNunchuk.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ArduinoNunchuk.cpp - Improved Wii Nunchuk library for Arduino 3 | * 4 | * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/ 5 | * 6 | * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/ 7 | * 8 | * Based on the following resources: 9 | * http://www.windmeadow.com/node/42 10 | * http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ 11 | * http://wiibrew.org/wiki/Wiimote/Extension_Controllers 12 | * 13 | */ 14 | 15 | #include 16 | #include 17 | #include "ArduinoNunchuk.h" 18 | 19 | #define ADDRESS 0x52 20 | 21 | void ArduinoNunchuk::init() 22 | { 23 | Wire.begin(); 24 | 25 | ArduinoNunchuk::_sendByte(0x55, 0xF0); 26 | ArduinoNunchuk::_sendByte(0x00, 0xFB); 27 | 28 | ArduinoNunchuk::update(); 29 | } 30 | 31 | void ArduinoNunchuk::update() 32 | { 33 | int count = 0; 34 | int values[6]; 35 | 36 | Wire.requestFrom(ADDRESS, 6); 37 | 38 | while(Wire.available()) 39 | { 40 | values[count] = Wire.read(); 41 | count++; 42 | } 43 | 44 | ArduinoNunchuk::analogX = values[0]; 45 | ArduinoNunchuk::analogY = values[1]; 46 | ArduinoNunchuk::accelX = (values[2] << 2) | ((values[5] >> 2) & 3); 47 | ArduinoNunchuk::accelY = (values[3] << 2) | ((values[5] >> 4) & 3); 48 | ArduinoNunchuk::accelZ = (values[4] << 2) | ((values[5] >> 6) & 3); 49 | ArduinoNunchuk::zButton = !((values[5] >> 0) & 1); 50 | ArduinoNunchuk::cButton = !((values[5] >> 1) & 1); 51 | 52 | ArduinoNunchuk::_sendByte(0x00, 0x00); 53 | } 54 | 55 | void ArduinoNunchuk::_sendByte(byte data, byte location) 56 | { 57 | Wire.beginTransmission(ADDRESS); 58 | 59 | Wire.write(location); 60 | Wire.write(data); 61 | 62 | Wire.endTransmission(); 63 | 64 | delay(10); 65 | } --------------------------------------------------------------------------------