22.11.08

think i should explain it really...

my boobs lighting up actually has a communicative purpose.

each LED shows when a certain word is found in this twitter feed.



and here's the code controlling it all:

arduino code:


//getting it to keep one light lit up

int timer = 10000000; // The higher the number, the slower the timing.
int happy[] = { 5, 6,}; // an array of pin numbers
int sad[] = { 7, 8 };
int meh[] = { 9, 10 };
int love[] = { 11, 12 };
int fuming[] = { 13, 14 };
int num_pins = 10; // the number of pins (i.e. the length of the array)
int val;

void setup()
{
Serial.begin(9600);

int i;

for (i = 0; i < num_pins; i++) // the array elements are numbered from 0 to num_pins - 1
pinMode(happy[i], OUTPUT); // set each pin as an output
pinMode(sad[i], OUTPUT);
pinMode(meh[i], OUTPUT);
pinMode(love[i], OUTPUT);
pinMode(fuming[i], OUTPUT);
}

void loop()
{
int i;

if (Serial.available()) {
val = Serial.read();
if (val == 'A') {
digitalWrite(happy[i], HIGH);
}
else {
digitalWrite(happy[i], LOW);
}


if (val == 'B') {
digitalWrite(sad[i], HIGH);
}
else {
digitalWrite(sad[i], LOW);
}

if (val == 'C') {
digitalWrite(meh[i], HIGH);
}
else {
digitalWrite(meh[i], LOW);
}

if (val == 'D') {
digitalWrite(love[i], HIGH);
}
else {
digitalWrite(love[i], LOW);
}

if (val == 'E') {
digitalWrite(fuming[i], HIGH);
}
else {
digitalWrite(fuming[i], LOW);
}
}


}


and the processing code:


//finds a word, sends a signal to the lilypad then stops the loop.

import processing.serial.*;

Serial port;

String[] tokens; //array
int counter;

void setup() {
size(100, 100);

println(Serial.list());
port = new Serial(this,Serial.list()[0], 9600);

//load file and split up words
String[] lines = loadStrings("http://twitter.com/allemotional");
String allText = join(lines, " ");
tokens = splitTokens(allText, " ,.?!:;[]-");

}

//so it's now pulling in that sentence and splitting it up.

void draw() {
background(255);
fill(0);

String s = tokens[counter];
counter = (counter +1) % tokens.length;
//look at the words one at a time please



//is the word there?
if (s.equals("happy")) {
println("happy");
port.write('A');
noLoop(); //DON'T LOOP IT BAHBEE.


}

if (s.equals("sad")) {
println("sad");
port.write('B');
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("meh")) {
println("meh");
port.write('C');
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("love")) {
println("love");
port.write('D');
noLoop(); //DON'T LOOP IT BAHBEE.

}

if (s.equals("fuming")) {
println("fuming");
port.write('E');
noLoop(); //DON'T LOOP IT BAHBEE.

}

}


i need to think more about the words that i'm looking for, they really need to reflect what people say in twitter.

No comments: