Wii nunchuck help
I was wondering how I would get the data from the nunchuck? their are four pins:
Red 3 volt
Green Data analog in 4
yellow wier clock / analog in 5
white wire ground
I was wondering if i would do the usual serin feature?
thanks for the help!!
Red 3 volt
Green Data analog in 4
yellow wier clock / analog in 5
white wire ground
I was wondering if i would do the usual serin feature?
thanks for the help!!

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The Nunchuk uses I2C, but it's rather picky about the speed. I've not tried the nunchuk on the Basic stamp, but I HAVE used it the the SX. On the SX you must slow down the standard I2C speed by about half.
If I get a chance, I'll try to get it working on the BS2.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
http://obex.parallax.com/objects/436/
that might give you some useful information.
DEVICE SX28, OSC4MHZ FREQ 4_000_000 ' Nunchuk connections ' White wire = Vss ' Red wire = Vdd ' Green wire = SDA (RA.0) ' Yellow wire = SCL (RA.1) LEDS PIN RB OUTPUT ' RB.0 and RB.1 show status of Nunchuk buttons SDA PIN RA.0 INPUT PULLUP SCL PIN RA.1 INPUT PULLUP ACK CON 0 NAK CON 1 temp VAR BYTE nunData VAR BYTE (6) ' NunChuk variables stickX VAR BYTE stickY VAR BYTE buttonZ VAR BIT buttonC VAR BIT AxisX VAR BYTE AxisY VAR BYTE AxisZ VAR BYTE ' Subs and functions I2C_START SUB 0 I2C_STOP SUB 0 I2C_SEND SUB 1 I2C_RECV FUNC 1,1 PROGRAM Start Start: ' Initialize Nunchuk I2C_Start I2C_Send $A4 I2C_Send $40 I2C_Send $00 I2C_Stop DO ' Request data from nunchuk I2C_Start I2C_Send $A4 I2C_Send $00 I2C_Stop PAUSEUS 200 ' Receive data from nunchuk I2C_Start I2C_Send $A5 PAUSEUS 20 ' If you omit this the first bit can read as a 1 even if it is a zero at fast clock speeds FOR temp = 0 TO 4 nunData(temp) = I2C_Recv ACK NEXT nunData(5) = I2C_Recv NAK I2C_Stop ' Translate nunchuk data FOR temp = 0 TO 5 nunData(temp) = nunData(temp) XOR $17 nunData(temp) = nunData(temp) + $17 NEXT ' Put data into variables stickX = nunData(0) - 128 stickY = nunData(1) - 128 axisX = nunData(2) - 128 axisY = nunData(3) - 128 axisZ = nunData(4) - 128 temp = nunData(5) buttonZ = ~temp.0 buttonC = ~temp.1 ' Show variables using signed values LEDs = temp BREAK WATCH stickX,8,SDEC WATCH stickY,8,SDEC WATCH axisX,8,SDEC WATCH axisY,8,SDEC WATCH axisZ,8,SDEC WATCH buttonZ WATCH buttonC LOOP END I2CSPEED 0.50 ' The nunchuk needs slow I2C communication SUB I2C_START I2CSTART SDA ENDSUB SUB I2C_STOP I2CSTOP SDA ENDSUB SUB I2C_SEND I2CSEND SDA, __PARAM1 ENDSUB FUNC I2C_RECV __PARAM5 = __PARAM1 I2CRECV SDA, __PARAM1, __PARAM5.0 RETURN __PARAM1 ENDFUNCBean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·