Nintendo Wii Nunchuck Object
crgwbr
Posts: 614
At the moment, I don't have the funds to buy a Wii nun chuck controller to use, so I could write an object for it. But I thought it might be useful to post some information on the com protocol I stumbled upon. The controller uses i2c for communication. The four wires coming out of the controller are the following:
white - ground
red - 3.3+v
green - data
yellow - clock
1. Send controller two bytes to start communication; $40 then $00
2. Send controller $00 every time you want feedback
3. Controller sends feedback in 6 byte packets
Thought this might help,
Craig
P.S. I found this information here
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech
I would love to change the world, but they won't give me the source code
People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.
I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"
white - ground
red - 3.3+v
green - data
yellow - clock
1. Send controller two bytes to start communication; $40 then $00
2. Send controller $00 every time you want feedback
3. Controller sends feedback in 6 byte packets
Byte Description Values of sample Nunchuk 1 X-axis value of the analog stick Min(Full Left):0x1E / Medium(Center):0x7E / Max(Full Right):0xE1 2 Y-axis value of the analog stick Min(Full Down):0x1D / Medium(Center):0x7B / Max(Full Right):0xDF 3 X-axis acceleration value Min(at 1G):0x48 / Medium(at 1G):0x7D / Max(at 1G):0xB0 4 Y-axis acceleration value Min(at 1G):0x46 / Medium(at 1G):0x7A / Max(at 1G):0xAF 5 Z-axis acceleration value Min(at 1G):0x4A / Medium(at 1G):0x7E / Max(at 1G):0xB1 6 Button state (Bits 0/1) / acceleration LSB Bit 0: "Z"-Button (0 = pressed, 1 = released) / Bit 1: "C" button (0 = pressed, 1 = released) / Bits 2-3: X acceleration LSB / Bits 4-5: Y acceleration LSB / Bits 6-7: Z acceleration LSB
Thought this might help,
Craig
P.S. I found this information here
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech
I would love to change the world, but they won't give me the source code
People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.
I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"
Comments
And if you don't need the buttons to work, you can disassemble it:
Post Edited (Bergamot) : 6/27/2007 8:36:55 PM GMT
I am triying to read the Nunchuck data·by means of I2C·(James Burrows´s i2cObject v2.1), following instructions of the top post, $40, $00 for initialization, and $00 for reading 6 bytes, one by one, with readByte object method (I´m at office and forgot code·in home laptop..·), but code is soo easy, 10·sentences.
The scan detecs Nunchuck ( I verified this plugging and unplugging Nunchuk from I2C bus) , but, all that I can read from Nunchuck is 255 x·6....
There are any problem with Fast I2C with propeller? Is there·any·I2C object for this or any change in the mentioned library? I am looking a lot, but I have found·nothing yet.
Thx!!!
·
Mike Green would be best to answer, but I believe the I2C object only runs at slow speed (100KHz?) not full-speed.
BTW: Your English is very readable
So, if you're at EADS, are you working on space-craft or UAVs? (Sorry - off-topic).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
I had to slow down the I2C to half-speed to get it to work correctly.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
The code that I test using basic_i2c_library doesn´t work:
·· oled.ftext(0,1,2, 255,255,255, string("Nunchuck Present"), 0 )
·· i2cObject.start (i2cSCL)
·· i2cObject.write (i2cSCL, nunchuckAddr )
·· i2cObject.write (i2cSCL, $40 )
·· i2cObject.write (i2cSCL, $00 )
·· i2cObject.stop (i2cSCL)
·· delay.pauseMSec (200)
·· i2cObject.start (i2cSCL)
·· i2cObject.write (i2cSCL, $00 )
·· repeat 5
····· buffer[noparse][[/noparse]ind++] := i2cObject.Read(i2cSCL,i2cObject#ACK)
·· buffer[noparse][[/noparse]ind++] := i2cObject.Read(i2cSCL, i2cObject#NACK)···
else
·· oled.ftext(0,1,2, 255,255,255, string("Nunchuck NO PRESENT"), 0 )