Thursday, December 13, 2007

Meet SpElmo

brought to you by Stella Kim and Andrea Dulko...

SpElmo has already been a great success. He's been met with enthusiasm and giggles and delivers a comical performance.

To give you an idea of how he was built...



In this picture you see that everything has been contained in a plant pot. Inside, there are two containers with waterpumps that pump the liquids up a tube that goes through his whole body and out of his mouth.



There is also a speaker hidden within the pot. We used big round balls that you find in children playhouses as buttons by poking them through sticks and then super gluing the ends of those sticks to keys on a computer usb keyboard that is also hidden within the pot. All the wires/plus come out through the bottom through two holes.



The design aspect was very difficult in the time frame we had. Although our prototype is some what a bit flimsy, for a prototype it is pretty sturdy and can withstand multiple plays. Who knew super glue could work THAT well. However, if we had more time, some of the design aspects we would rethink would be the buttons. Although we like the buttons themselves, the arrangement and mechanics of it we are not completely happy with. That was probably the hardest part of our project, figuring out the best way to make the buttons function in a sturdy manner.

Now to the electronics...

In order to activate the pumps we used a simple 5v relay that can be found at any radioshack.



We originally tested out our pumps with a different kind of relay that we found at digikey that look like this...



Unfortunately, when we tried to order more of these they were completely sold out and wouldn't be able to send it to us until...well...a long time. So we used the ones from radioshack that didn't look as cool but it still ended up working fine.

Now you're probably wondering WHY we didn't go and use the relays from Radioshack in the first place. Well for some reason we thought we would have to do this whole complicated business where we would need two relays plus a 9v power ac just to activate one pump. It turned out that all we really needed to look at were the Amps...the 5v relay from radioshack takes up to 1 Amp, and the pump takes less than 1 Amp to power it so ...presto...everything turned out to be pretty easy peasy.

So by hooking up the pumps to the arduino via our 5v relays we were in business. After that we exported bytes from the arduino program to Processing where we wrote most of our code. We used letter key presses and a couple strings and arrays to implement and arrange the words (which we pre-made) and sounds.

When you start the program, a word sounds. You start to spell by pushing the big buttons down then up to initiate the letter. When you press a key, you hear the sound of the letter to let the player know that the key has been pressed. After you finish entering the letters you pressed a big button labeled '1'. '1' is the ENTER key and '2' is the clear key if you made a mistake and wish to start over. If you entered incorrectly there will be sound that lets the player know they spelled wrong and must try again, meanwhile Elmo vomits the non-alcoholic beverage. If the word was spelled correctly then there is a sound that activates to let the player know that they were right, and Elmo vomits an alcoholic beverage.

The Code


Arduino


//Spelmo
//by Stella Kim and Andrea Dulko

int BadPump = 9;
int GoodPump= 7;

byte goal = 5;
byte noGoal= 4;

byte incomingByte = 0; // for incoming serial data


void setup()
{
// begin the serial communication
Serial.begin(9600);
pinMode(BadPump, OUTPUT);

digitalWrite(BadPump, HIGH); // turn on the LED
delay(300);
digitalWrite(BadPump, LOW); // turn on the LED
delay(300);
digitalWrite(BadPump, HIGH); // turn on the LED
delay(300);
digitalWrite(BadPump, LOW); // turn on the LED
delay(300);


pinMode(GoodPump, OUTPUT);

digitalWrite(GoodPump, HIGH); // turn on the LED
delay(300);
digitalWrite(GoodPump, LOW); // turn on the LED
delay(300);
digitalWrite(GoodPump, HIGH); // turn on the LED
delay(300);
digitalWrite(GoodPump, LOW); // turn on the LED
delay(300);
}


void loop() {


if (Serial.available() > 0) { // first check if there's any serial info to be read

incomingByte = Serial.read(); // read the incoming byte:


if(incomingByte==noGoal){
digitalWrite(BadPump, HIGH); //TURN on bad pump
delay(8000);
digitalWrite(BadPump, LOW); //turn off bad pump
}

if(incomingByte==goal){
digitalWrite(GoodPump, HIGH); //TURN on good pump
delay(3000);
digitalWrite(GoodPump, LOW); //turn off bad pump
}

}
}



Processing

//Spelmo
//by Stella Kim and Andrea Dulko

import ddf.minim.*;
import processing.serial.*;
int curr;


String [] goals = {
"", "dog", "joy", "hanukkah", "pitch", "aristotle", "transistor", "octopus", "flower", "record", "highness", "blackout", "restroom",
"transform", "jiggle", "resistor", "caterpillar"};




AudioPlayer[] playerb = new AudioPlayer[2];
String[] playerBFiles = {
"wrong.mp3", "ohgodno.mp3"};



String answer = "";

boolean awesomeWill;
//boolean wordSounds;

boolean ManUrocks;


AudioPlayer[] player = new AudioPlayer[26];
String[] playerFiles = {
"A.mp3", "B.mp3","C.mp3", "D.mp3", "E.mp3", "F.mp3", "G.mp3",
"H.mp3", "I.mp3", "J.mp3", "K.mp3", "L.mp3",
"M.mp3", "N.mp3", "O.mp3", "P.mp3", "Q.mp3", "R.mp3", "S.mp3",
"T.mp3", "U.mp3", "V.mp3", "W.mp3", "X.mp3",
"Y.mp3", "Z.mp3" };


AudioPlayer[] playerA = new AudioPlayer[16];
String[] playerAFiles = {
"dog.mp3", "joy.mp3", "hanukkah.mp3", "pitch.mp3", "aristotle.mp3", "transistor.mp3", "octopus.mp3", "flower.mp3", "record.mp3", "highness.mp3",
"blackout.mp3", "restroom.mp3", "transform.mp3", "jiggle.mp3", "resistor.mp3", "caterpillar.mp3"};

Serial port;

byte lastByte = 0; //record previous byte


void reply(){
if (lastByte != 1) {
port.write(1);
lastByte = 1;
}
}

void setup()
{

size(710, 480);

Minim.start(this);
for (int i = 0; i < playerFiles.length ; i++) {
player[i] = Minim.loadFile(playerFiles[i]);
}

for (int k = 0; k < playerBFiles.length ; k++) {
playerb[k] = Minim.loadFile(playerBFiles[k]);
}


for (int curr = 0; curr < playerAFiles.length ; curr++) {
playerA[curr] = Minim.loadFile(playerAFiles[curr]);
}
playerA[int(random(5))].play();

println("Available serial ports:");
println(Serial.list());

port = new Serial(this, Serial.list()[0], 9600);
// playerA[1].play();


}

void draw()
{



for (int i = 0; i < playerFiles.length ; i++) {
if(keyPressed) {
char[] alphabet = {
'A','B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
char[] alphabetsmall = {
'a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v' ,'w', 'x', 'y', 'z'
};
for (int j = 0; j < alphabet.length; j++){
if (key == alphabet[i] || key == alphabetsmall[i]) {

player[i].rewind();
player[i].play();

reply();

}


}


}
}


}



void keyReleased(){

answer= (answer + key);
println (answer);
for (int i = 1; i < goals.length; i++) {

if (goals[i].equals(answer)){
println("SETTING TO TRUE");
awesomeWill=true;
break;
}
else {
if (keyCode != ENTER) {
awesomeWill=false;
}
}


if ((awesomeWill== true)&&(keyCode==ENTER)){
println("awesomewill true AND enter");

//delay(1000);
playerb[1].rewind();
playerb[1].play();
delay(3000);
playerA[curr++].play();
playerA[curr].rewind();
answer=goals[0];
port.write(4);
lastByte=4;
// ManUrocks=false;

break;
}
else if ((awesomeWill== false)&&(keyCode==ENTER)){
println("awesomewill false AND enter");

// ManUrocks=true;
answer=goals[0];
playerb[0].rewind();
playerb[0].play();
println("WHERE IS THE SONG!?");
port.write(5);
lastByte=5;
break;
}



if (keyCode == BACKSPACE){
answer=goals[0];
}


if (lastByte != 2) {
port.write (2);
lastByte = 2;
}
}




}



void stop() {
for (int i = 0; i < playerFiles.length; i++) {
player[i].close();
super.stop();
}

for (int k = 0; k < playerBFiles.length; k++) {
player[k].close();
super.stop();
}
}



Unlike other drinking games, where the loser has to drink more alcoholic beverage, SpElmo works the opposite way. The point of the game is NOT to get drunker but to have a good time. We reward those with alcohol that are still coherent and not completely wasted. We want our players to have the chance to succeed in spelling and perhaps maybe even learn how to spell a new word.