« November 2008 | Main | March 2009 »

January 2009 Archives

January 29, 2009

Wii Controller + Processing

You need Darwiin remote and a wii remote and a bluetooth adapter. This reads a text file from the Darwiin and then utilizes it in processing and it shows up as movement.

PImage wiimote_top, wiimote_front;
int accX, accY, accZ, orientation;

void setup()
{
size(600, 400);
frameRate(60 );

smooth();

//wiimote_top = loadImage("shake.jpg");
//wiimote_front = loadImage("turn.jpg");
}

void draw()
{
background(0);
fill(255);
ellipse(400.0,300.0, 50, 50);

// load the textfile generated from DarwiinRemote and converts it into strings
String [] wiimote_file = loadStrings("/wiimote.txt");

if (wiimote_file.length == 1)//this if statement reads the TXT file and converts
//it into movement.
{
String [] wiimote_values = wiimote_file[0].split(";");

accX = Integer.parseInt(wiimote_values[0]);
accY = Integer.parseInt(wiimote_values[1]);
accZ = Integer.parseInt(wiimote_values[2]);

orientation = Integer.parseInt(wiimote_values[3]);
}

ellipse(132-accX/2.0, 190-accY/2.0, 300,400);

translate(width/2, 70);
if(orientation == 1)
rotate(-PI/2);
else if(orientation == 2)
rotate(PI);
else if(orientation == 3)
rotate(PI/2);
//rect(wiimote_front, -wiimote_front.width/2, -wiimote_front.height/2);
}

About January 2009

This page contains all entries posted to Daniel Ponce in January 2009. They are listed from oldest to newest.

November 2008 is the previous archive.

March 2009 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31