Shop OBEX P1 Docs P2 Docs Learn Events
Wireless Nunchuck? It works! — Parallax Forums

Wireless Nunchuck? It works!

RaymanRayman Posts: 14,652
edited 2015-04-03 17:39 in Propeller 1
There's cool OBEX code for the Wii Nunchuck...
Thought my wireless version would be a great way to control my BoeBot (with SpinStamp).

But, I can't get this Nyko version to work...
I just ordered a Mad Catz version off Amazon for $13.

Anybody get any of the wireless nunchuck's working with the Prop?


See below: Jon's code works with Nyko Kama wireless nunchuck that I got from Amazon.

Comments

  • JonnyMacJonnyMac Posts: 9,105
    edited 2011-03-06 16:49
    Ray,

    The attached object works with a genuine Wii Nunchuk and is *supposed* to work with off-brands and wireless as well -- for non-Nintendo controllers there is a slight variation in the protocol (which works for all nunchuk controllers).

    I just finished this about an hour ago. Please let me know if it works for you.
  • RaymanRayman Posts: 14,652
    edited 2011-03-06 18:30
    Jon, thanks. Like the code. It works with regular Nunchuck, but not my Nyko wireless.

    I'm hopefull the one I just ordered from Amazon will be more cooperative...
  • JonnyMacJonnyMac Posts: 9,105
    edited 2011-03-06 20:27
    Here's another version to try. This one uses the "new" protocol and sends sends the zero three times before reading channel values. It also returns the controller ID which should help you know if you have a connection.

    For full disclosure, all of this stuff is based on Arduino programs I've found on the 'net. I've attached one that has been helpful.
  • RaymanRayman Posts: 14,652
    edited 2011-03-07 03:48
    Jon, Ok I'll try it out tonight, thanks. I'm not very optomistic though because I've also tried every trick that Google could find for me...

    The receiver has a blue led that comes on as soon as it's plugged into the wiimote, but nothing i've tried makes it turn on. It does communicate though and I'm able to get the correct ID. It was very fustrating! So close, yet so far...

    I'll work harder on the new unit that's coming Wednesday. I'll sniff the init sequence, if I have to...
    When it works, it has to be the cheapest way to add wireless control to a system...

    BTW: Wouldn't this plus the motion plus device make for a 6DOF IMU?
  • RaymanRayman Posts: 14,652
    edited 2011-03-07 14:12
    Tried it... No luck.
  • RaymanRayman Posts: 14,652
    edited 2011-03-17 02:39
    Got the Mad Catz Z-Chuck wireless nunchuck and tried it... Also, no luck.

    I'll have to take it apart now and probe the wires to see what's going on... Might take a while to find time for that...
  • xanaduxanadu Posts: 3,347
    edited 2015-03-26 07:03
    Have you tried a longer delay before starting the I2C? MyNyko seems to need at least two seconds before it will talk. The wireless also needs to be paired first, so I put in a five second delay before wii.init to give me plenty of time to pair it.

    Edit: Just noticed the date on this, I'm behind the times on wiipherals!
  • User NameUser Name Posts: 1,451
    edited 2015-03-26 08:45
    xanadu wrote: »
    Edit: Just noticed the date on this, I'm behind the times on wiipherals!

    Hey, so am I. Glad you bumped this thread because I didn't know of its existence (2010-2011 was a very busy period). It is always great to have another handy input device (no pun intended).
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-03-26 09:04
    User Name wrote: »
    It is always great to have another handy input device (no pun intended).

    BTW, I'm using a wireless Wii Nunchuck in my Halloween Hex. Here's a link:
    http://forums.parallax.com/showthread.php/157497-Halloween-Hex?p=1321718&viewfull=1#post1321718

    I have lots of different remote control devices but the wireless Nunchuck is my current favorite. Jon's driver make it really easy to use.
  • RaymanRayman Posts: 14,652
    edited 2015-03-26 11:38
    I'll have to try adding a delay to the I2C driver. Didn't think of that... Hope it works...
  • xanaduxanadu Posts: 3,347
    edited 2015-03-26 15:13
    Duane Degn wrote: »
    BTW, I'm using a wireless Wii Nunchuck in my Halloween Hex. Here's a link:
    http://forums.parallax.com/showthread.php/157497-Halloween-Hex?p=1321718&viewfull=1#post1321718

    I have lots of different remote control devices but the wireless Nunchuck is my current favorite. Jon's driver make it really easy to use.

    I can see why, it is a great little controller and for the price I'd be hard pressed to find one complaint about it. I did have one other issue, the buttons C and Z were swapped, so C's output would show button Z, no big deal.

    Thanks Duane and Jon for the info and code, I woke up at 4am to program my latest project, will update my thread soon.
  • RaymanRayman Posts: 14,652
    edited 2015-03-31 16:33
    Just got a new "Kama" wireless nunchuk today (couldn't find the parts for my old ones).

    Tried several times an couldn't make it work...

    But, then I re-downloaded Jon's ver2 from above in this thread.
    At first it didn't work. Tried with regular Nunchuck and it worked. Retried with wireless and added delay and it worked!

    Took delay out and it still worked.

    So, I'm happy, but still wondering why it didn't work at first. Now, I can't make it not work...

    PS: Went back to original V2 files and it still works every time. Guess I can't complain.

    BTW: The Nyko Kama version seems nicer because it has blue leds that indicate connection and activity status in a more obnoxious way that is helpful.
  • xanaduxanadu Posts: 3,347
    edited 2015-03-31 18:01
    I think Jon's code is the only code on this forum and in the OBEX that works with newer controllers. The i2C objects may work but the way the nunchuk is addressed changed or something...

    To init my wireless nunchuk I do this:
    PUB wiiinit                            ' wait until wii wireless is paired
    
      wii.init(SCL, SDA)                   ' setup Wii
      
      waitcnt(clkfreq / 1 + cnt)           
     
      repeat
        wii.scan 
        if wii.joyx > 180
         'wii.stop
         waitcnt(clkfreq / 1 + cnt) 
         wiiinit 
        if wii.joyx < 180
         manualcontrol
    
       waitcnt(clkfreq / 500 + cnt)  
      
      
    PUB manualcontrol
    
        wii.scan 
    
    
    

    It looks for a valid center value from the joystick before continuing into my main program. There is also a status LED that shows the program is stuck in that loop, which helps immensely! Give yourself some indicators of what is going on until you get used to how it behaves.

    There are times the Nyko reciever needs a power reboot, no matter what you do it will not work until it is rebooted on the receiver side. The best way to prevent this is to get a good initial init, and keep it that way.

    Don't let the controller go out of range. Flashing code can make the Nyko lock up, not always but often especially after a few Propeller reboots with power constantly applied to the Nyko rx.

    Once you're done programming and using it to control something it will become much easier, I consider it very reliable.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-03-31 18:23
    I use the "Idpntr" method to get the location of the Nuchuck's ID and test to make sure the value isn't -1 after calling the init method.

    Here's my NunchuckInit method.
    PUB InitNunchuck(readAttempts) | localPtr
    
      localPtr := Nunchuck.Idpntr
      repeat readAttempts
        Nunchuck.Init(I2C_CLOCK, I2C_DATA)
        bytemove(@result, localPtr, 4)
        Pst.Str(string("Nunchuck ID = $"))
        Pst.Hex(result, 8)
        if result <> -1
          quit
    
    

    The program checks the returned value from "InitNunchuck" and treats returned values of zero and -1 as a failed init.

    The actual value returned is always the same on the Nyko Nunchucks but I'm not sure if the value is the same as the Wii Nunchucks.

    I use the receiver on the pin 28 and 29. This has occasionally prevented new programs from being loaded to EEPROM correctly. This isn't a problem very often and when it does occur, I unplug the receiver from the little adapter I use and then reconnect it once the new program has been loaded.

    Edit: I had recently modified this method. The earlier version of this method worked fine my my modifications introduced a bug. I should have tested the modified code prior to posting it. The current version appears to work as expected.
  • RaymanRayman Posts: 14,652
    edited 2015-04-01 02:28
    Duane, somehow I missed details in your earlier post... I see now you had success with the exact same wireless Nunchuck. (Also happened to see that the forum is starting new and all old threads becoming read only.)

    Also, I guess xanadu was talking about this Nyko wireless Nunchuck earlier too...

    Anyway, seems we're all happy with Nyko.
  • xanaduxanadu Posts: 3,347
    edited 2015-04-01 07:26
    Glad you got it working, I thought your post said you couldn't get it to work at the end, now I see it says you can't not get it to work lol.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-04-02 10:06
    Just in case anyone is using my init code, I just fixed a bug in it.

    I hadn't included the address symbol "@" in the line:
    bytemove(@result, localPtr, 4)
    

    Sorry for posting untested code.
  • xanaduxanadu Posts: 3,347
    edited 2015-04-03 17:39
    We will try to find a way to forgive you, I can only speak for myself it wasn't that hard :)
Sign In or Register to comment.