Classic Wii Remote Not Returning Values

Serial Monitor is not returning values at all,not even zero. These are the steps.

  1. Download codes
  2. Open Serial Monitor
    I used the example codes here: Arduino Playground - WiiClassicController

Arduino is communicating with the computer and is running example programs but not with the Classic Wii Controller. What am I doing wrong?

Oh, I am using the Arduino Uno

What am I doing wrong?

Not telling us what you are doing. There are quite a few things you could be doing wrong, from copying and pasting your code to wiring it wrong.....Please post pictures, schematics and code.

Sorry about that. Here are the codes I used.

/*
WiiClassic Test Code

This code prints the current controller status to the serial port.
Button pressed calls poll whether the button was pressed since the last update call.
as a result, it will just briefly print the last button pressed once.

Tim Hirzel May 2008

*/

#include "Wire.h"

#include "WiiClassic.h"

WiiClassic wiiClassy = WiiClassic();

void setup() {
Wire.begin();
Serial.begin(9600);
wiiClassy.begin();
wiiClassy.update();
}

void loop() {
delay(100); // 1ms is enough to not overload the wii Classic, 100ms seems to ease the serial terminal a little
wiiClassy.update();

//
/*
// PRINT RAW BYTES FOR DEBUG
// STATUS IS FIRST FOUR BYTES
for (int i = 0; i < 4; i ++) {
for (int j = 7; j >= 0; j--) {
if ((wiiClassy.getRawStatus() & (1 << j)) == 0) {
Serial.print("0");
}
else{
Serial.print("1");
}
}
Serial.println();
}
// BUTTONS IS NEXT TWO BYTES
for (int i = 0; i < 2; i ++) {
for (int j = 7; j >= 0; j--) {
if ((wiiClassy.getRawButtons() & (1 << j)) == 0) {
Serial.print("0");
}
else{
Serial.print("1");
}
}
Serial.println();
}
Serial.println("---");
*/
Serial.print("Buttons:");
if (wiiClassy.leftShoulderPressed()) {
Serial.print("LS.");
}
if (wiiClassy.rightShoulderPressed()) {
Serial.print("RS.");
}
if (wiiClassy.lzPressed()) {
Serial.print("lz.");
}
if (wiiClassy.rzPressed()) {
Serial.print("rz.");
}
if (wiiClassy.leftDPressed()) {
Serial.print("LD.");
}
if (wiiClassy.rightDPressed()) {
Serial.print("RD.");
}
if (wiiClassy.upDPressed()) {
Serial.print("UD.");
}
if (wiiClassy.downDPressed()) {
Serial.print("DD.");
}
if (wiiClassy.selectPressed()) {
Serial.print("select.");
}
if (wiiClassy.homePressed()) {
Serial.print("home.");
}
if (wiiClassy.startPressed()) {
Serial.print("start.");
}
if (wiiClassy.xPressed()) {
Serial.print("x.");
}
if (wiiClassy.yPressed()) {
Serial.print("y.");
}
if (wiiClassy.aPressed()) {
Serial.print("a.");
}
if (wiiClassy.bPressed()) {
Serial.print("b.");
}
Serial.println();
Serial.print("right shoulder: ");
Serial.println(wiiClassy.rightShouldPressure());
Serial.print(" left shoulder: ");
Serial.println(wiiClassy.leftShouldPressure());
Serial.print(" left stick x: ");
Serial.println(wiiClassy.leftStickX());
Serial.print(" left stick y: ");
Serial.println(wiiClassy.leftStickY());
Serial.print(" right stick x: ");
Serial.println(wiiClassy.rightStickX());
Serial.print(" right stick y: ");
Serial.println(wiiClassy.rightStickY());
Serial.println("---");
//pulse = (int)500+8*wiiClassy.leftStickX();
//updateServo();
}
[Get Code]
•WiiClassic.h library
/*
* Wii Classic -- Use a Wii Classic Controller
* by Tim Hirzel http://www.growdown.com
*
*
* This code owes thanks to the code by these authors:
* Tod E. Kurt, http://todbot.com/blog/_

The Wii Nunchuck reading code is taken from Windmeadow Labs_

* http://www.windmeadow.com/node/42_

and the reference document on the wii linux site:
* http://www.wiili.org/index.php/Wiimote/Extension_Controllers/Classic_Controller
/_
_
#include <Wire.h>_
#ifndef WiiClassic_h*

#define WiiClassic_h
*class WiiClassic { *
* private:*
* byte cnt;*
* uint8_t status[4]; // array to store wiichuck output*
* byte averageCounter;*
* //int accelArray[3][AVERAGE_N]; // X,Y,Z*
* uint8_t buttons[2];
uint8_t lastButtons[2];
_
public:_
_
void begin()_
_
{_
_
Wire.begin();_
_
cnt = 0;_
_
averageCounter = 0;_
_
Wire.beginTransmission (0x52); // transmit to device 0x52*_
* Wire.send (0x40); // sends memory address*
* Wire.send (0x00); // sends memory address*
* Wire.endTransmission (); // stop transmitting*
* lastButtons[0] = 0xff;*
* lastButtons[1] = 0xff;*
* buttons[0] = 0xff;*
* buttons[1] = 0xff;*
* update(); *
* }*
* void update() {*
* Wire.requestFrom (0x52, 6); // request data from nunchuck*
* while (Wire.available ()) {*
* // receive byte as an integer*
* if (cnt < 4) {*
* status[cnt] = nunchuk_decode_byte (Wire.receive()); //nunchuk_decode_byte ()
_
} else {*

* lastButtons[cnt-4] = buttons[cnt-4];*
* buttons[cnt-4] =nunchuk_decode_byte (Wire.receive());
_
}*

* cnt++;*
* }*
* if (cnt > 5) {*
* send_zero(); // send the request for next bytes*
* cnt = 0; *
* }*
* }*
byte * getRawStatus() {

* return status;*
* }*
_ byte * getRawButtons() {_
* return buttons;*
* }*
* boolean leftShoulderPressed() {*
* return PressedRowBit(0,5);
_
}*

* boolean rightShoulderPressed() {*
* return PressedRowBit(0,1);
_
}*

* boolean lzPressed() {*
* return PressedRowBit(1,7);
_
}*

* boolean rzPressed() {*
* return PressedRowBit(1,2);
_
}*

* boolean leftDPressed() {*
* return PressedRowBit(1,1);
_
}*

* boolean rightDPressed() {*
* return PressedRowBit(0,7);
_
}*

* boolean upDPressed() {*
* return PressedRowBit(1,0);
_
}*

* boolean downDPressed() {*
* return PressedRowBit(0,6);
_
}*

* boolean selectPressed() {*
* return PressedRowBit(0,4);
_
}*

* boolean homePressed() {*
* return PressedRowBit(0,3);
_
}*

* boolean startPressed() {*
* return PressedRowBit(0,2);
_
}*

* boolean xPressed() {*
* return PressedRowBit(1,3);
_
}*

* boolean yPressed() {*
* return PressedRowBit(1,5);
_
}*

* boolean aPressed() {*
* return PressedRowBit(1,4);
_
}*

* boolean bPressed() {*
* return PressedRowBit(1,6);
_
}*

* int rightShouldPressure() {*
* return status[3] & 0x1f; //rightmost 5 bits*
* }*
* int leftShouldPressure() {*
* return ((status[2] & 0x60) >> 2) + ((status[3] & 0xe0) >> 5); //rightmost 5 bits*
* }*
* int leftStickX() {*
* return ( (status[0] & 0x3f) );*
* }*
* int leftStickY() {*
* return ((status[1] & 0x3f)); *
* }*
* int rightStickX() {*
* return ((status[0] & 0xc0) >> 3) + ((status[1] & 0xc0) >> 5) + ((status[2] & 0x80) >> 7);*
* }*
* int rightStickY() {*
* return status[2] & 0x1f; *
* }*
* private:*
* boolean PressedRowBit(byte row, byte bit) {
_
byte mask = (1 << bit);*

* return (!(buttons[row] & mask )) && (lastButtons[row] & mask);*
* }*
* byte nunchuk_decode_byte (byte x)
_
{*

* x = (x ^ 0x17) + 0x17;*
* return x;*
* }*
* void send_zero()
_
{*

* Wire.beginTransmission (0x52); // transmit to device 0x52*
* Wire.send (0x00); // sends one byte*
* Wire.endTransmission (); // stop transmitting*
* }*
};
#endif

What is showing up in the serial monitor? Can we see a picture and schematic of your hardware?

Nothing is showing up on the serial monitor. I have attached a picture of the hardware and the serial monitor.

Also, I can't get the code to communicate with my Classic Wii Controller. After downloading my codes sucessfully, when I press the joysticks/buttons on the controller, nothing moves ad there is no light change on the victors. Please help. My competition is next Saturday!

Maybe your classic controller was burned by powering it on 5v while its desigined for 3.3v. try with another controller, and connect it to 3.3v. because I2C is 5V, its recomended to use a logic level converter or 2 voltage dividers and diodes. you can made this like:

arduino A4 or A5--10K-|- 5.6K--Gnd
| |
|----<diode<--wiimote

Repeat this two times for the two wires.

I don't believe the wiimote is grounded. Before following the above advice, add the following function to the end of your pde file and call it at the very beginning of setup()

// Uses port C (analog in) pins as ground for Nunchuck
static void nunchuck_setpowerpins()
{

#define gndpin PORTC2
    DDRC |= _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    delay(100);  // wait for things to stabilize        
}

How would you call it at the begining of setup() ? (I'm really new to arduino)

after the line
void setup(){

and before the line

wire.begin

just add the line:

nunchuck_setpowerpins();