12.12.08
the final thing
this is what it looks like, and that's what it all means.
final 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/fiowantscoffee");
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
// mood uno: cuppa -------------------------------------------------------------------------------
if (s.equals("coffee")) {
println("coffee");
port.write('A');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood zwei: love -------------------------------------------------------------------------------
if (s.equals("love")) {
println("love");
port.write('B');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood tres: sex -------------------------------------------------------------------------------
if (s.equals("sex")) {
println("sex");
port.write('C');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood funf: fail -------------------------------------------------------------------------------
if (s.equals("fail")) {
println("fail");
port.write('D');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood six: internet -------------------------------------------------------------------------------
if (s.equals("internet")) {
println("internet");
port.write('E');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood seiben: twitter -------------------------------------------------------------------------------
if (s.equals("tweet")) {
println("tweet");
port.write('F');
noLoop(); //DON'T LOOP IT BAHBEE.
}
// mood acht: geeking out -------------------------------------------------------------------------------
if (s.equals("geek")) {
println("geek");
port.write('H');
noLoop(); //DON'T LOOP IT BAHBEE.
}
}
final arduino code:
//getting it to keep one light lit up
int timer = 10000000; // The higher the number, the slower the timing.
// geeking
int geek[] = { 3, 4 };
// fail
int fail[] = { 5, 6 };
//internet
int net[] = { 7, 8 };
int twitter[] = { 9, 10 };
// cuppa
int drink[] = { 11, 12,};
// sex
int sex[] = { 13, 14 };
// love
int loves[] = { 15, 16 };
int num_pins = 18; // 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(drink[i], OUTPUT);
pinMode(loves[i], OUTPUT);
pinMode(sex[i], OUTPUT);
pinMode(fail[i], OUTPUT);
pinMode(net[i], OUTPUT);
pinMode(twitter[i], OUTPUT);
pinMode(geek[i], OUTPUT);
}
void loop()
{
int i;
if (Serial.available()) {
val = Serial.read();
//cuppa --------------------------------------------------------------------------
if (val == 'A') {
digitalWrite(drink[i], HIGH);
}
else {
digitalWrite(drink[i], LOW);
}
//love --------------------------------------------------------------------------
if (val == 'B') {
digitalWrite(loves[i], HIGH);
}
else {
digitalWrite(loves[i], LOW);
}
//sex --------------------------------------------------------------------------
if (val == 'C') {
digitalWrite(sex[i], HIGH);
}
else {
digitalWrite(sex[i], LOW);
}
//fail --------------------------------------------------------------------------
if (val == 'D') {
digitalWrite(fail[i], HIGH);
}
else {
digitalWrite(fail[i], LOW);
}
//internet----------------------------
if (val == 'E') {
digitalWrite(net[i], HIGH);
}
else {
digitalWrite(net[i], LOW);
}
//twitter --------------------------------------------------------------------------
if (val == 'F') {
digitalWrite(twitter[i], HIGH);
}
else {
digitalWrite(twitter[i], LOW);
}
//geeking out --------------------------------------------------------------------------
if (val == 'H') {
digitalWrite(geek[i], HIGH);
}
else {
digitalWrite(geek[i], LOW);
}
}
}
that's all a lot shorter than i wanted it to be, but oh well.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment