View Single Post
  #5   Spotlight this post!  
Unread 03-02-2014, 13:39
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 186
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: I2C Arduino Port (Wii MotionPlus)

Your explanation of the addresses makes sense and clears things up.

I realized I misread your first post and didn't catch the difference between your snippet and mine.

Quote:
Originally Posted by kylelanman View Post

Code:
/* Arduino */
void receiveData(){
  Wire.beginTransmission(0x52);    //now at address 0x52
  Wire.send(0x00);		     //send zero to signal we want info
  Wire.endTransmission();
  nunchuck)
  Wire.requestFrom(0x52,6);	  //request the six bytes from the WM+
  for (int i=0;i<6;i++){
    data[i]=Wire.receive();
  }
}
Code:
/* WPILib */
        // _wmp is an instance of I2C
	uint8_t buffer[6];
	_wmp->Transaction(0x00, 1, buffer, sizeof(buffer);
Quote:
Originally Posted by Mike Bortfeldt View Post

Code:
_wmp->Transaction(0x00, 0, buffer, sizeof(buffer));
With my 1 transaction call I was trying to kill 2 birds with one stone. The Wii MotionPlus requires that you send 0x00 in order for it to return data. That is why I was using a size of 1. Will this work all in one transaction or do we need to do 2 separate transactions. 1 for sending 0x0 and the other for receiving?

Thanks

Kyle
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

Reply With Quote