How I got my Wiimote to control a Scratch Game

How I got my Wiimote to control a Scratch Game

Image

This blog is something of a howto (especially for myself – when I forget how I did it next week &

have to rerun the entire process!!), something of a moan about how many hurdles I had to

jump to get this to work & Im hoping something of an encouragement to similar non technical

‘ICT turned Computing’ teachers who would like to do similar projects and think they are the

only one who doesn’t know their script from their scratch.

Several months ago now @MartinBateman demonstrated a game he

had made in scratch that was then controlled by a wiimote.

Here’s Martin’s presentation from that Raspberryjam on YouTube…

I thought this would be an excellent classroom project to encourage

the kids to make scratch games. Especially if I allowed them up to play it on the

whiteboard at the end of the lesson as a reward for the best design.

So I accessed Martin’s blog & downloaded the Python code he recommends HERE in the video…..

Image

http://www.star.uclan.ac.uk/~mb/rpjam3sept2012.html

I already have python 2.6 & 3.2 (http://www.python.org/getit/)

so once I’d copied & pasted the code in I thought it would be as simple as pressing run.

Maybe its me being naive but when you’re used to using MSoffice & passing any slightly

technical hiccup to IT support hitting a hurdle that you’re going to have to solve yourself is quite daunting.

Anyway the hiccup presented itself in the form of bad indentation that neither version of python liked.

Given that this was script I had never seen before & my python is still fairly amateur I finally got

it to run & had a momentary swell of pride that I’d dealt with the problem myself.

 Image

That was when it spat back an error message about not having the cwiid library! 8….-(

An HOUR of googling later I slowly started to realise that this cwiid thing is just for

Linux & having searched desperately for a Windows version and finding nothing I had

to accept that it wasn’t going to work for me on a W7 pc.

Feeling uncharacteristically brave after my earlier success with the indents & having

had several cups of coffee at this point….

Image

I decided – how hard can it be ….. so I googled around and found this game on the Scratch website.

http://scratch.mit.edu/projects/rubiks_cube_guy238/1182359

Again, naively, I just pressed go & expected it to just work… I mean why wouldnt it? 🙂

It didn’t.

I went searching through the associated forum and found reference to something

called GlovePi. Which I then downloaded from here…

http://download.chip.eu/en/GlovePie-0.30_174835.html

I found a tutorial series on YouTube, here…..

& I had to google how to enable my bluetooth here…

http://www.ehow.com/how_5844478_connect-nintendo-wii-remote-computer.html

Image

I even had to google how to make the wiimote discoverable!

http://nintendowiiremote-with-windows7.articles.r-tt.com/

I C&Ped the code from the scratch forum here….

http://scratch.mit.edu/forums/viewtopic.php?id=87154

into GlovePi hit run & tried to play the game…

Image

(About half an hour later after finally getting an old bluetooth dongle that actually worked…)

Image

After fiddling with the code a little (as you can see above) so that I didn’t die

instantly every time I started the game.

I had success!! 🙂

My next mission is to actually learn how the code works – Ive made a start on this already by following the YouTube tutorials about GlovePie mentioned above. So far Ive just turned the lights on & off, but I saw a nice example of counting to 10 in binary using the lights – I think I’ll try that. 🙂

Image

was done using this code….

Image

row 2, cell 1 row 2, cell 2

There are some other fun projects using GlovePie and a Wiimote here.

Advertisements

One thought on “How I got my Wiimote to control a Scratch Game

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s