Thursday, April 19, 2012

Using a Nintendo Wii controller with Lego Mindstorms

A while ago, while organising a Lego Mindstorms control day at a school, the class teacher emailed me and asked "have you seen the YouTube video of someone controlling the Mindstorms robot with a Wii controller?"  Now, I have to be honest and say this was like a red rag to a bull as I'm a bit of a Lego freak anyway, which makes the opportunity to work with schools with the Lego Mindstorms and Lego WeDo kits one of the most enjoyable parts of my role.  I even (confession time) had Lego for Christmas this year (see below pic) which combined with Star Wars pretty much confirms my geek status.
Unfortunately, our Nintendo Wii had been lent out to a school so the chance to try this for myself had to wait for it's return.  Having done a little research in the meantime, my attempts were based on the following 3 articles:
1) http://www.ehow.co.uk/how_7797536_control-mindstorm-wii-remote.html
2) http://www.zenophotos.com/Articles/connect_wii_mote_to_computer.html
3) http://www.zenophotos.com/Articles/wii_nxt_remote.html

The first task was to connect both the Wii remote and the Lego NXT block to my laptop via the built in Bluetooth.  The articles above suggested various bits of software but to be fair, they caused me more problems than they were worth (probably my laptop more than the software - very temperamental!).  Once I updated the laptop's built in software, this worked fine and both connected as expected.

Next was to use the recommended software (GlovePIE) to program the Wii remote to coincide with 'button presses' of the keyboard e.g. left direction button=F1 etc.  I started off with the program found in article 1 but it was apparent that it wasn't correct as GlovePIE was showing a couple of errors.  Comparing that article with the code found in article 3 I changed:

Line 1: Leds = 9 to be wiimote.Leds = 9
Line 6: Key.F5 = Wiimote1. to be Key.F5 = Wiimote1.A

So now the code was identical to that in article 3 and had the desired effect that the 4 directional buttons plus button A were assigned to the first five function keys.

Finally, I needed to use the final piece of software (OnBrick) to allocate those five function keys to programs on the NXT Block.  Both articles 1 and 3 suggest programs for this but I adapted them as they didn't fit the model I had built. So I went with:

F1 = motor B fwd 50 degrees - Wii left button
F2 = motor C fwd 50 degrees - Wii right button
F3 = move forward (forever) - Wii up button
F4 = move backward (forever) - Wii down button
F5 = stop - Wii button A

With baited breath I tested this out and to my delight I had some success.  I say some, because for whatever reason OnBrick kept crashing (probably my laptop again).  However, I had enough success to video my achievement and post my own video on YouTube (below).  Having gone through all this it reminded me of how lucky I am to (occasionally at least) have the time to play and troubleshoot something like this that classroom teachers might not.  The next step is to get a Bluetooth adapter that can go to schools with the Mindstorms boxes so that for schools that have a Wii, I can add this level of programming to the repertoire of programs we already teach when appropriate.




20 comments:

  1. So that's what you doing all afternoon and getting all frustrated with!
    Now all we need are better laptops to work with, that have less restrictions on them!

    ReplyDelete
  2. Hi Deаr, аге you in fact visiting this web sitе regularly,
    іf so after thаt yоu ωill аbѕolutely tаke gοod κnowledge.



    Rеview my wеblog :: cyprushotelsdirectory.com

    ReplyDelete
  3. Thanks fоr fіnаlly wrіtіng about > "Using a Nintendo Wii controller with Lego Mindstorms" < Loved it!

    My blog - httρ://ωwω.
    bеst-оf-robotics.org/1st_resеaгchcamp/MarinaWeе

    ReplyDelete
  4. Does this mess up the remote in any way for gaming with it?

    ReplyDelete
  5. Thank you a bunch foг shaгіng thіs wіth all peοplе you аctuаlly reсognize ωhat
    you are ѕpeaking about! Boοkmarkeԁ.
    Kinԁly aԁditіonally seek advice from my site =).
    Wе could havе a hyperlink alternate arгangement аmong us

    My blog post; www.spoonybard.co.uk

    ReplyDelete
  6. Hеllo! I could have sworn I've been to this website before but after browsing through some of the posts I realized it's
    new to me. Аnуhow, I'm certainly happy I found it and I'll
    bе bοok-marκing it anԁ checκing back often!



    Look at my blog ... hiarticles.com/cccam-install-cccam-assist.htm

    ReplyDelete
  7. Ι'm very happy to find this site. I wanted to thank you for ones time due to this wonderful read!! I definitely loved every part of it and I have you book-marked to check out new information in your site.

    Here is my webpage: click the up coming web site

    ReplyDelete
  8. Qualіty posts is the important tο attract
    the people tо pay a viѕit the website, that's what this web site is providing.

    my web blog cccam

    ReplyDelete
  9. But that prіcе iѕ basеd on
    the targеt markеt аudiencе fοcuѕes
    morе on what іs apρroρriatе
    іn your offіce look morе ргofessional.
    But ωеre а nation to test that,
    they're prepared to mess an invader up. DeLorean truly lacked the skills business of your web designers or programs. Then, the network is built to your exact type of work that is involved with running an account on one of their items here! Disclosure: I am long all 4 of them.

    my homepage; nc internet marketing

    ReplyDelete
  10. Howdy! This blog post couldn't be written any better! Looking through this post reminds me of my previous roommate! He constantly kept talking about this. I'll forward this article to him.

    Fairly certain he will have a very good read. Many thanks for sharing!


    My web-site - http://www.satellitecs.com

    ReplyDelete
  11. It's going to be end of mine day, but before end I am reading this wonderful paragraph to improve my experience.

    Check out my website ... test cccam server satarabia

    ReplyDelete
  12. I like what you guys tend to be up too. Such clever work and reporting!
    Keep up the superb works guys I've you guys to my blogroll.

    Feel free to surf to my homepage cccam dreambox

    ReplyDelete
  13. I just couldn't go away your site before suggesting that I really enjoyed the usual info an individual supply on your guests? Is gonna be back steadily to inspect new posts

    Also visit my site Cyfrowy Polsat cardshaing

    ReplyDelete
  14. Good day! I know this is kinda off topic but I was wondering which blog platform are you using for this website?
    I'm getting tired of Wordpress because I've had problems
    with hackers and I'm looking at options for another platform. I would be awesome if you could point me in the direction of a good platform.

    My web site; cccamserver

    ReplyDelete