Interfacing to Wii Nunchuck


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default Interfacing to Wii Nunchuck

    I'm trying to interface a Wii Nunchuck to a PIC using PBP.

    From the info on this page (http://wiibrew.org/wiki/Wiimote/Exte...ollers#Nunchuk), I have written what I think should work, but not having much joy.

    Code:
    'init nunchuck: write $55 to $A400F0 and $00 to $A400FB
    
    I2CWRITE i2c_clock_pin,i2c_data_pin,$A4,$00F0,[$55],fail
    pause 10
    i2CWRITE i2c_clock_pin,i2c_data_pin,$A4,$00FB,[$00],fail
    pause 10
    
    
    'read 6 bytes from $A40008
    
    I2CREAD i2c_clock_pin,i2c_data_pin,$A4,$0008,[STR datain/6]
    However each time I read the 6 bytes i get one of three sets of bytes back (each time I read I get the next set, and then it loops back to the 1st set).

    Code:
    80,FF,7F,7F,7F,7F
    FF,FF,7F,7F,7F,7F
    FB,FF,7F,BF,DF,EF
    Does anyone have any ideas? Has anyone successfully used a nunchuck in PBP?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Ok, I worked it out. The main problem is I needed to use:

    Code:
    DEFINE I2C_HOLD 1
    And then the following code works:

    Code:
    init:
    
    i2cwrite i2c_clock_pin,i2c_data_pin,$A4,$F0,[$55]
    pause 1
    i2cwrite i2c_clock_pin,i2c_data_pin,$A4,$FB,[$00]
    pause 1
    
    main:
    
    i2cwrite i2c_clock_pin,i2c_data_pin,$A4,[$00]
    pause 1
    i2cread i2c_clock_pin,i2c_data_pin,$A4,[STR datain/6]
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Nice

    Wondering what you are building for the WII ?

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RFsolution View Post
    Nice

    Wondering what you are building for the WII ?
    I'm using the nunchuck for the 3-axis accelerometer. Next step is to interface a Wii Motion Plus too for the 3-axis gyroscope. I'm going to combine the two for a full 6 degrees of freedom sensor. The trickiest part of this will be the Kalman filter which involves some pretty heavy maths.

    I'm doing all this because eventually i want to design and build one of these:
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    I'm doing all this because eventually i want to design and build one of these:
    Oh man.... I WANT one!


    steve

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Byte_Butcher View Post
    Oh man.... I WANT one!
    That was exactly my reaction. They are selling kits, but they are hugely expensive. I figured it would be more fun to design one from scratch anyway. I think i'll start with a 4 rotor version.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts