WiiMote IR Camera with Arduino


This post shows how to extract the IR Camera from the WiiMote and connect it to a .NET micro framework board (FEZ Domino in my case).

The present blog is simply a porting of the C# code to Arduino code, in case anybody is interested…

It’s a very basic file, really showing just the minimum necessary to get it working.


#include <Wire.h>

const byte ADDR_SENSOR = 0xB0 >> 1;
byte buff[2];
byte recvBuff[13];

int x, y, s;

void setup(){
Serial.begin(115200);
Wire.begin();

send(0x30, 0x01 );
send( 0x30, 0x08 );
send( 0x06, 0x90 );
send( 0x08, 0xC0 );
send( 0x1A, 0x40 );
send( 0x33, 0x03 );
send( 0x30, 0x08 );

delay(100);
}

void loop(){
readData();
Serial.print(x); Serial.print(" / "); Serial.print(y); Serial.print(" / "); Serial.println(s);
delay(300);
}

void readData()
{
send( 0x36 );
Wire.requestFrom(ADDR_SENSOR, (byte)13);
for(byte i=0; i<13; i++) recvBuff[i] = Wire.receive();

// have no idea why the 1st BLOB start at 1 not 0....
byte offset = 1;
x = recvBuff[offset];
y = recvBuff[offset + 1];
int extra = recvBuff[offset + 2];
x += (extra & 0x30) << 4;
y += (extra & 0xC0) << 2;
s = (extra & 0x0F);
}

void send(byte val){
Wire.beginTransmission(ADDR_SENSOR);
Wire.send(val);
Wire.endTransmission();
delay(10);
}

void send(byte val1, byte val2){
Wire.beginTransmission(ADDR_SENSOR);
buff[0] = val1; buff[1] = val2;
Wire.send(buff, 2);
Wire.endTransmission();
delay(10);
}

One Response to WiiMote IR Camera with Arduino

  1. Pingback: WiiMote IR Camera with Lego NXT Brick – LeJOS « Robotics / Electronics / Physical Computing

Leave a comment