Let's Make Robots!

Using a wiimote with processing to control your robots

Communicates with your pc to control your robot
FireTracker.zip1.16 KB

The wiimote is a really cool controller to use with your robots. It has many buttons, accelerometers and even a camera which tells the coordinates of the four principal IR emitters that it sees.

There are many examples of applications using it, some of the most populars are from Johnny Chung Lee. But there are much more, just search for "wiimote" or "wiimote robot" on youtube or google. Here on LMR we have some examples too:

And others with just its camera:

But I wanted to use it, without having to hack it, to communicate with processing and control my robot TheBox.

On my computer I have installed WIDCOMM bluetooth software which I found here.

If you've never used processing you should take a look here

To install the processing libraries I followed this tutorial.

I had some problems placing the folders so here is a simple scheme:

+ Prossessing

    + libraries

        + Loc

            + library

                - Loc.jar

            + lll

                + Loc

                     - ...

        + wrj4P5

            + library

                - bluecove-2.1.0.jar

                - bluecove-gpl-2.1.0.jar

                - WiiRemoteJ.jar

                - wrj4P5.jar

                - Loc.jar (optional)

            + lll

                + wrj4P5     

                    - ...

To test if it is all working you can try these examples found here:

If they work, you can pass to the next step, the serial communication with your robot.

The application MyFirstWii is really easy to adapt. On the movie you can see my robot TheBox using it.

All you have to do is to import the serial library, create a serial object, define the COM port & the baud rate and add the serial communication where the data about the buttons is analyzed. Here is an example:

import processing.serial.*;

import lll.wrj4P5.*;

Wrj4P5 wii;

Serial TheBox;

void setup() {


  wii=new Wrj4P5(this);


  TheBox = new Serial(this, "COM5", 4800);

void draw() {





  rotateX((int) (wii.rimokon.senced.x*30+300));

  rotateY((int) (wii.rimokon.senced.y*30+300));

  rotateZ((int) (wii.rimokon.senced.z*30+300));



void buttonPressed(RimokonEvent evt, int rid) {

   if (evt.wasPressed(RimokonEvent.TWO)) println("2");

   if (evt.wasPressed(RimokonEvent.ONE)) println("1");

   if (evt.wasPressed(RimokonEvent.B)) {




   if (evt.wasPressed(RimokonEvent.A)) println("A");

   if (evt.wasPressed(RimokonEvent.MINUS)) println("Minus");

   if (evt.wasPressed(RimokonEvent.HOME)) println("Home");

   if (evt.wasPressed(RimokonEvent.LEFT)){




   if (evt.wasPressed(RimokonEvent.RIGHT)){




   if (evt.wasPressed(RimokonEvent.DOWN)){




   if (evt.wasPressed(RimokonEvent.UP)){




   if (evt.wasPressed(RimokonEvent.PLUS)) println("Plus");


I didn't found the IR Sensor Tesr application  easy to understand and modify, so I decided to write a new one which I believe it's more practical to use:


import lll.wrj4P5.*;

import lll.Loc.*;


Wrj4P5 wii;


float x;

float y;

float w;

float h;


//Change here:

 //Size of the window

   int camWidth = 512;

   int camHeight = 384;

 //Number of IR Emmiters that you want to track

   int IREmitters = 4;



void setup() {


  wii=new Wrj4P5(this).connect(Wrj4P5.IR);




void draw() { 

//Defines Background color



//Draws ir emitters

  for (int i=0;i<IREmitters;i++) {

    Loc p=wii.rimokon.irLights[i];

    if (p.x>-1) {

     // Reads the value sent by the wiimote and multiplicities them by the size of the window






     //Prints the values to the console


       print(" ");


       print(" ");


       print(" ");



     //Draws the circles



       ellipse(x, y, w, h);


     //Draws the lines



       line(0,y,camWidth, y);







I developed this code and created another application to my robot which you can download here. It seems to work well, but how the robot is having some motors problems, I didn't had chance to test it with it, but you can see the test I did on the second movie. The application uses this library




Comments, advices, doubts and suggestions are always welcome! :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I've tried the application IR Sensor Test and it works well, at least it detects my lighter. 

Next thing I want to do is to modify that code to send data to my robot and make it capable of finding  candles. I will post the result here or in my robot's page.

Thats amazing - and very responsive - i will have to have a closer look at the myfirstwii methods - luckily i have the widdcom stack already installed.

Did you try using the IR camera yet ? -  as this is where the wii can help with navigation.

Thanks for posting this info - bluetooth is a nightmare - however once set up its pretty bombproof.

I've been thinking about buying a wiimote from dealextreme.com as they are pretty cheap.  I miss using them for powerpoint presentations using GlovePIE.

Nice! I see this as a good way to do home navigation. How? Install 4 IR LEDs on the ceiling and have the IR camera on the robot looking at the ceiling. Camera being I2C, I suppose it is easy to interface with any microcontroller. Care to try that?

RobotFreak made a good tutorial about using the camera as a standalone sensor and used it to make a firefighting robot. So I guess that it is not very hard. But I don't want to destroy my wiimote for now, thats why I'm using it this way. I think I'll try your idea soon, using processing. 

this is awesome!

This is just the beginning ;D