Monday, March 15, 2010

Two Wii Nunchucks with one arduino

In the midst of a senior design project, it was decided that we wanted to use 2 Wii Nunchucks as accelerometers to measure orientation of a human arm ( 1 for the upper arm and 1 for the forearm). In understanding I2C communication, there is no way to use 2 Nunchucks on the same I2C bus without some sort of external circuitry. (All nunchucks have the same slave address, leaving nothing to distinguish between the two when attempting to receive data).

I drew up a simple and cheap solution to interface two (or more) Wii Nunchucks on the same I2C bus. This is useful for projects that require multiple accelerometers at a cheap price.

Here is all you will need:

2 npn switching transistors (I used 2N3904)
2 current limiting resistors (I used 200 Ohm)




Just connect all nunchuck Power (PWR), Clock (SCL), and Ground (GND) wires to the same corresponding spots on your microcontroller. The microcontroller's SDL can be connected to the outputs of both transistors.

Programming notes:

In order to perform a read, all you have to do is set the pin of the corresponding transistor to HIGH (5v in our case), write/read to the I2C bus, then set that pin to LOW (0v)to disconnect that nunchuck from the bus. Also, during start up you must initialize each nunchuck individually in order to operate both nunchucks correctly.
Good luck,
B Dwyer (aka: johnnyonthespot)

8 comments:

  1. Hi there,

    I'm very interested in that solution!
    What do you mean by "during start up you must initialize each nunchuck individually"?

    Best regards,
    Lr

    ReplyDelete
  2. In the WiiChuck Library there is a function called Init() which will initialize the variables for each nunchuck object you create. You must initialize each when connected to the correct nunchuck in order for future update() calls to work correctly.

    -BD

    ReplyDelete
  3. I can send you the WiiChuck library if you are interested (for Arduino)

    -BD

    ReplyDelete
  4. Doing a search for 2N3904 brings up a lot of different options with different specs. Can you provide more information on this part, or better yet a part number from someplace like digikey? Thanks

    ReplyDelete
    Replies
    1. Most specs will do just fine. You can also use a multiplexer to do the same function, with higher reliability.

      Delete
  5. Nunchucks were originated in ancient Japan and a lot of techniques have been developed since then. Are thinking How to Use Nunchucks in the best way? There are a lot of techniques and tricks of using Nunchucks i.e. you can block with them, strike with them, then there is the famous hand roll technique and the complex figure eight technique which you can try.

    ReplyDelete
  6. That is something unique. Well I hope your project about Nunchucks gone well.

    ReplyDelete
  7. The term nunchucks makes the mind wander into the direction of the mesmerizing and astonishing display of Bruce Lee and his Nunchucks. His spectacle paved the way for the popularity of the nunchucks in the world of martial arts.

    ReplyDelete