Go Down

Topic: Interfacing DJ Hero Controller via I2C, always one byte missing (Read 746 times) previous topic - next topic

darkside40

Hi there,
i have a strange problem when i try to interface my DJ Hero Turntable or  Guitar Hero World Tour Controller with my Arduino Uno.

I have written the following sample code which schould just initialize the Controller and print me the six byte i request into the serial console:

Code: [Select]
#include <Wire.h>

#define BAUDRATE 19200
#define ADDRESS 0x52

void setup()
{
   Serial.begin(BAUDRATE);
   
   Wire.begin();
   Wire.beginTransmission(ADDRESS);     
   Wire.write(0xF0);
   Wire.write(0x55);
   Wire.endTransmission();
   delay(1);
   Wire.beginTransmission(ADDRESS);
   Wire.write(0xFB);
   Wire.write((uint8_t)0x00);
   Wire.endTransmission();
}

void loop()
{
  int count = 0;     
  int values[6];

  Wire.requestFrom (ADDRESS, 6);
   
  while(Wire.available())
  {
    values[count] = Wire.read();
    count++;
  }
 
  Serial.println(values[0], BIN);
  Serial.println(values[1], BIN);
  Serial.println(values[2], BIN);
  Serial.println(values[3], BIN);
  Serial.println(values[4], BIN);
  Serial.println(values[5], BIN);
  Serial.println("-------------------");
 
  Wire.beginTransmission(ADDRESS);
  Wire.write((uint8_t)0x00);
  Wire.write((uint8_t)0x00);
  Wire.endTransmission();
  delay(1000);
 
}


That works, except for that i miss the first byte which holds (for example) information about the x-axis of the controllers analoge stick.
That means in my case the last byte is always 0 and the byte before are shifter one position higher (so the first byte is not there and the second ist now first).

I tried the same code with my Guitar Hero controller and have the same problem.
But the code works with the Nintendo Nunchuk.

The only really valuable Information regarding the controller i got from http://wiibrew.org/wiki/Wiimote/Extension_Controllers/DJ_Hero_%28Wii%29_Turntable

Has anybody  a idea what could be wrong with my code?
Problem exists with Arduino 1.0 and 1.01 on Mac OS X.

frank26080115

Code: [Select]

 Wire.beginTransmission(ADDRESS);
 Wire.write((uint8_t)0x00);
 Wire.write((uint8_t)0x00);
 Wire.endTransmission();


is wrong, what that does is "set pointer to 0x00, write 0x00 into where you are pointing"

each write auto-increments the pointer, that's why you are missing the first byte, because the write operation skipped it

Code: [Select]

 Wire.beginTransmission(ADDRESS);
 Wire.write((uint8_t)0x00);
 Wire.endTransmission();


is correct, what that does is "set pointer to 0x00, wait for a read operation from where you are pointing"
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

darkside40

Great that works now.

Thank you so much frank26080115.

Now i can start converting the byte to something usefull and pack it into a library, so that other peolple coud use that to interface that controller.

Go Up