Wii Nunchuck interface object
Jo
Posts: 55
The Wii Nunchuck is a neat (and cheap) controller. 3-axis accelerometer, joystick and 2 buttons,
all neatly packaged in a convenient case. The interface is i2c and decoding isn't too complex,
though it has some weird conventions.
I looked around and didn't see any prebuild objects for accessing it from the propeller, neither on
OBEX nor on these forums, so attached is a simple object to talk to it. This object depends on (but
does not include) the i2cObject (obex.parallax.com/objects/217/)
I've connected mine to Propeller pins 28,29; these are the same pins the propeller uses to talk
to its EEPROM and so already have the pull up resistors (besides, reusing those pins just leaves
more pins free to do other stuff). If you're breaking open the Nunchuck cable, pin 28 (SCL) connects
to the yellow wire, pin 29 (SDA) connects to the green wire. However, feel free to connect it to
any other pins (but remember to make the appropriate changes to the pins used to run the i2c
protocol in the Nunchuck object)
You can also very easily make a small double sided PCB that inserts into the nunchuck controller and
gives access to all the pins:
1 - green - data
2 - nothing
3 - red - 3.3+v
4 - yellow - clock
5 - nothing
6 - white - ground
--
Jo
all neatly packaged in a convenient case. The interface is i2c and decoding isn't too complex,
though it has some weird conventions.
I looked around and didn't see any prebuild objects for accessing it from the propeller, neither on
OBEX nor on these forums, so attached is a simple object to talk to it. This object depends on (but
does not include) the i2cObject (obex.parallax.com/objects/217/)
I've connected mine to Propeller pins 28,29; these are the same pins the propeller uses to talk
to its EEPROM and so already have the pull up resistors (besides, reusing those pins just leaves
more pins free to do other stuff). If you're breaking open the Nunchuck cable, pin 28 (SCL) connects
to the yellow wire, pin 29 (SDA) connects to the green wire. However, feel free to connect it to
any other pins (but remember to make the appropriate changes to the pins used to run the i2c
protocol in the Nunchuck object)
You can also very easily make a small double sided PCB that inserts into the nunchuck controller and
gives access to all the pins:
______ | 1 2 3 | | | | 6 5 4 | |_-----_|
1 - green - data
2 - nothing
3 - red - 3.3+v
4 - yellow - clock
5 - nothing
6 - white - ground
--
Jo
Comments
Among other things that I would like to do, one of them is to create this interface. Now I can scratch that off my list and add "play with the prebuilt method". I have a Nunchuck sitting here next to my prop, I just need to find time in the day to do it. For those that don't have a Nunchuck, I recommend picking up a used one at a game store for $10 to $15. Those should be good enough to start playing with. This is certainly a great interface object for various applications.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com·- Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto fo SunSPOT, BitScope
www.sxmicro.com - a blog·exploring the SX micro
www.tdswieter.com
Going to have to drop this into OBEX as soon as I have some time.
If anyone has any suggestions on how to make it better or anything, feel free to drop me a line or reply to this subject.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
Jo
http://store.fungizmos.com/index.php?main_page=product_info&cPath=69&products_id=212
I've also noticed that there's an NES gamepad that works the same way (I2C):
http://www.amazon.com/Wii-Classic-Controller-nintendo/dp/B000IN0BSU
This looks to be a really cool way to integrate a controller into a design.· And, it can use the existing I2C bus, thereby not using any pins...
Nice find! Ordered a few of those myself.
OBC
Edit: I got free shipping on those Wii PCB's (US) because they were the only thing I ordered.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Post Edited (Oldbitcollector) : 11/8/2008 2:48:35 AM GMT
Jim
The Wii Classic controller looks awesome.. Now to wait for those breakout boards.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Using it an an interface for this game would be cool..
www.youtube.com/watch?v=V8d_aJwikfk - {Master of the Lamp}
(Of course porting the entire game to the Prop even better.)
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Ideas that come to my head:
1. Wii Nunchuch and XBee for wireless control of bot(s)
2. Wii Nunchuch as pointing device to control a cursor on a screen.
3. Two Wii Nunchuchs for prop pong.
The first idea I've been thinking about for a while, actually.
I'm looking forward to playing with these tonight.
Thanks again Ray for spotting this.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Later:
Man, I love the Propeller. About 45 minutes worth of tinkering, and it's up and running, thanks to that object you wrote.
This is so cool.
Post Edited (sylvie369) : 11/11/2008 12:11:08 AM GMT
I see how to use the joystick (joyX and joyY), and I see how to read the buttons (buttonC and buttonZ), but I'm having trouble interpreting the accelX, accelY, and accelZ.
If I hold the Wii Nunchuk in my hand and rotate my wrist left and right, the accelX value goes from about -200 to +200 And, if I rotate my wrist forward and back the accelY value goes from -200 to +200. The accelZ value keeps changing, but I don't see a pattern there.
Do these X, Y, and Z values somehow compute into a point in a 3-D coordinate space?
Do you think that the Wii System uses the actual values X, Y, and Z, or does it somehow use the changes in the values of X,Y, and Z to track the game player's motion when waving the controller?
These values by themselves are not coordinates in 3D space. If you knew your position however and then knew your acceleration you could calculate velocity and thus distance from that known position. Make sense? This isn't easy to do because there are all sorts of errors that could accumulate that need to be accounted for.
In the Wii and in your code there should be processing algorithms. There probably isn't a "This value of accelX = this action". You coudl do that, nothing wrong with it. But more of a algorithm for detecting changes and how much change is what is used to detect motion.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
I'm going to start with the Smart Sensors and Applications course, and then go back to learning about Wii Nunchuk controller.
The theory part first: as we live on earth, there is a constant 1G gravitational field accelerating us down all the time. So, if the nunchuck is being held still
(so that there are no extra acceleration forces) regardless of orientation, the dot product all the acceleration sensors will be constant (and represents
1g in the sensor units).
The direction of the resulting vector indicates which way the nunchuck is being held.
The formulae:
X := accelX()
Y := accelY()
Z := accelZ()
acceleration := X*Y+Y*Z+Z*X
Generally acceleration is constant *unless* the nunchuck is being moved in some direction, in which cases it increases when it is accelerated/decelerated.
The orientation can then be figured out:
roll := atan2(X, Z)
pitch := acos(Y/acceleration)
NOTE that the nunchuck cannot detect yaw (rotation on the horizontal plane).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
Jo
In the serial terminal I'm getting:
255,255,1023,1023,1023,0,0
Over and over again.
I have the greed wire hooked up to pin 29, yellow to 28, white to GND, and red to 3.3, as per the instructions.
Any ideas why the values aren't changing, no matter what I do with the Nunchuck?
John Abshier
Try slowing down the I2C speed and see if that helps. In SX/B you must you 1/2 the default speed.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
www.iElectronicDesigns.com
·
Edit. I found the address scanning function in the i2c demo. It shows addresses $A0 and $A4 acknowledging, I tried using both address. Still nothing.
Post Edited (Jay Kickliter) : 12/11/2008 10:44:36 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
like I say, though, I'm pretty sure it's a real nintendo one, is there a definitive way to confirm it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
One final note. Joao, thank you so much for this contribution. I was not looking forward to the work required just to see if my POC is sound and you just saved me tons of work. Thanks again!
Post Edited (soshimo) : 12/20/2008 4:20:04 AM GMT
Can't wait to get mine working too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]
This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.