Sunday, December 13, 2009

Project Process

The code for my piece went relatively well for me. I didn't have much difficulty creating it and getting it to function properly. Here are some example codes that I looked at for the project.




EXAMPLE 1

// two 12 VDC solenoids
int S1 = 4; // digital pin 4 solenoid 1
int S2 = 2; // digital pin 2 solenoid 2
int val;
int count;

void setup()
{
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
Serial.begin(9600); // begin serial communication with the computer at 9600 bps
}

void loop()
{ // start the loop

for (int count=0; count <= 3; count++) // flip solenoids back and forth three times
{
digitalWrite(S1, HIGH);
digitalWrite(S2, LOW);
delay(1000);
digitalWrite(S1, LOW);
digitalWrite(S2, HIGH);
delay(1000);
}
for (int count=0; count <= 3; count++) // flip solenoids back and forth three times only faster
{
digitalWrite(S1, HIGH);
digitalWrite(S2, LOW);
delay(500);
digitalWrite(S1, LOW);
digitalWrite(S2, HIGH);
delay(500);
}
for (int count=0; count <= 2; count++) // flip solenoids back and forth two times, even faster
{
digitalWrite(S1, HIGH);
digitalWrite(S2, LOW);
delay(250);
digitalWrite(S1, LOW);
digitalWrite(S2, HIGH);
delay(250);

digitalWrite(S1, HIGH); //rat-a-tat-tat. Listen to the beat!
delay(100);
digitalWrite(S1, LOW);
delay(100);
digitalWrite(S1, HIGH);
delay(100);
digitalWrite(S1, LOW);
delay(100);
digitalWrite(S2, HIGH);
digitalWrite(S1, HIGH);
delay(250);
digitalWrite(S2, HIGH);
digitalWrite(S1, HIGH);
delay(250);
}
}



EXAMPLE 2



int red = 2;
int blue = 3;
int green = 4;


void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Wave test!");

pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
}

void loop() {
char c;

if (Serial.available()) {
c = Serial.read();
Serial.println(c, BYTE);
if (c == 'h') {
digitalWrite(red, HIGH);

}

} else {
return;
}

}


Here is my first attempt at writing the code for this project:


int x = 100;
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o = 255;
PFont




void setup() {
size(700,750);
background(0);



}
void draw() {
fontA = loadFont("Square721BT-Roman-40.vlw");
textFont(fontA, 40);
fill(255);
text("How are you feeling today?",x,40);
fontA = loadFont("Square721BT-Roman-20.vlw");
textFont(fontA, 20);
fill(a);
text("Happy",80,90);
fill(b);
text("Energetic",150,90);
fill(c);
text("Distant",260,90);
fill(d);
text("Angry",355,90);
fill(e);
text("Melancholic",430,90);
fill(f);
text("Hurt",560,90);
fill(g);
text("Content",x,130);
fill(h);
text("Anxious",200,130);
fill(i);
text("Dissapointed",295,130);
fill(j);
text("Curious",440,130);
fill(k);
text("Tired",530,130);
fill(l);
text("Confused",150,170);
fill(m);
text("Amorous",260,170);
fill(n);
text("Envious",360,170);
fill(o);
text("Other",460,170);

fill(155,100,20);
rect(0,190,699,559);
fill(255);
rect(40,230,619,479);

}

For this... there were a few certain little quirky errors that didn't function properly but this was my start for designing the interface.

No comments:

Post a Comment