3V3 SDA
: :
.-----:-----:-----.
| ___________ |
| | | | 1 = 3V3
| | n n n | | 1 3 5 2 = SCL
| | ======= | | 3 = N/C
| | u u u | | 2 4 6 4 = N/C
| |___________| | 5 = SDA
| | 6 = 0V
| .--:-----:--. |
`--' : : `--'
: :
SCL 0V
SDA 3V3
: :
.-----:-----:-----.
| ___________ |
| | u u u | | 5 3 1 1 = 3V3
| | | | 2 = SCL
| | | | 3 = N/C
| | | | 4 = N/C
| |__n__n__n__| | 6 4 2 5 = SDA
| | 6 = 0V
| .--:-----:--. |
`--' : : `--'
: :
0V SCL
The cheapest one we saw on line was 8 bucks. Hate to pay that much!!you need a motion plus which you can open up and easily remove the socket from
power them from a PICAXE I/O pin???They are low current so it is recommended to power them from a PICAXE I/O pin so they can be power-cycled.
'20Nchk1 reads joystick and buttons
#picaxe 20x2
Symbol joystick_x = b30
Symbol joystick_y = b31
Symbol Accel_X = b32
Symbol Accel_y = b33
Symbol Accel_z = b34
Symbol Accel_buttons = b35 ' lower 2 bits of accel & Z,C button states
Symbol xOld = b36
Symbol yOld = b37
Symbol CZ0old = bit0 ' CZ0 and CZ1 describe button positions:
Symbol CZ1old = bit1 ' 00=Z pressed; 01=both pressed ; 10=C pressed ; 11=neither pressed
Symbol changed = bit2
Symbol CZ0 = bit24 ' CZ0 and CZ1 describe button positions:
Symbol CZ1 = bit25 ' 00=Z pressed; 01=both pressed ; 10=C pressed ; 11=neither pressed
Symbol nunchukaddress = $A4
Init:
pause 10
hi2csetup i2cmaster, nunchukaddress, i2cslow, i2cbyte
hi2cout ($40,$00)
pause 1
main:
do
gosub readNunchuk
changed = 0
if CZ0 <> CZ0old then
changed = 1
CZ0old = CZ0
endif
if CZ1 <> CZ1old then
changed = 1
CZ1old = CZ1
endif
if joystick_x <> xOld then
changed = 1
xOld = joystick_x
endif
if joystick_y <> yOld then
changed = 1
yOld = joystick_y
endif
if changed = 1 then
sertxd(#joystick_x, " ", #joystick_y, " ", #CZ0, " ", #CZ1,cr,lf)
endif
' pause 2000
loop
readNunchuk:
hi2cout (0)
' pause 1
hi2cin (joystick_x,joystick_y,Accel_X,Accel_Y,Accel_Z,Accel_buttons)
b3 =Accel_buttons^0x17 + 0x17 'decrypt button state
' '"Z" Button pressed = 00 or 01
' '"C" button pressed = 01 or 10
'Bits 2-3: X acceleration 2 LSBs
'Bits 4-5: Y acceleration 2 LSBs
'Bits 6-7: Z acceleration 2 LSBs
joystick_x= joystick_x^0x17 + 0x17 'Decrypts x-axis Value of joystick
'Min(Full Left): 46
'Medium(Center): 172
'Max(Full Right): 255
joystick_y=joystick_y^0x17 + 0x17 'decrypts y-axis value of joystick
'Min(Full Down): 46
'Medium(Center): 131
'Max(Full Right): 255
return
$8 is expensive but it can be a good investment and will prove indispensable if you want to test other controllers. It's just so much easier to plug a controller in, no need to open, no need to cut wires or work out how it is wired, and it remains undamaged so can still be used with a Wii, reused by someone else.The cheapest one we saw on line was 8 bucks. Hate to pay that much!!you need a motion plus which you can open up and easily remove the socket from
Chopping the plug off!!!