//CODE |

Version Compare

Back to page history

Version User Scope of changes
Nov 18 2007, 10:00 PM EST (current) little_ms_chewbacca 50 words added, 68 words deleted
Nov 18 2007, 9:58 PM EST little_ms_chewbacca 201 words added

Changes

Key:  Additions   Deletions


-------------------------------------------------

// PROCESSING code - _8by8_mouse_reveal_.pde
// eddie SIMULATION code. this reveals a baby face when mouse 8x8 cursor
// moves over it. will work on more accurate representation.


void setup() {
size(640,640);
background(250,200,100);
}
//
void draw() {
fill(255);
noStroke();
// stroke(0);
//strokeWeight(1);
// rectMode(CENTER);
rect(mouseX,mouseY,64,64);



noFill();
stroke(250,200,100); //change back to bg color!
strokeWeight(1);
arc(width/2+10,height/2+15,9,4,PI,PI/2);
arc(width/2-10,height/2+15,9,4,PI,PI/2);


noStroke();
fill(250,200,100); //change back to bg color!
beginShape();
ellipse(width/2, height/2+40,75,15);
endShape();
ellipse(width/2-36, height/2-40, 38, 18);
ellipse(width/2+36, height/2-40, 38, 18);
noFill();
strokeWeight(1);
stroke(250,200,100);
ellipse(width/2, height/2-32, 180, 242);
arc(width/2+32,height/2-55,50,4,PI/2,3*PI/2);
arc(width/2-32,height/2-55,50,4,PI/2,3*PI/2);
}



-------------------------------------------------
// PROCESSING code- Photocells_5_talking_erl_WORKS.pde
// code to test 5 photo resistors. last time i checked it worked.
// these photo resistors seem like they might be a tiny bit finicky.
// use this with the ARDUINO code below...


import processing.serial.*; //calls serial library

Serial port;
int[] serialInArray = new int[5];
int serialCount = 0;
int gs1,gs2,gs3,gs4,gs5; //greyscale values for squares
boolean madeContact = false; //Whether or not we've heard from the arduino

void setup() {
size(640,640);
noStroke(); //no borders
println(Serial.list());
port = new Serial(this, Serial.list()[0], 9600);//usually uses 0, first available
port.write(65); //send an A to start up Arduino

gs1 = 0;
gs2 = 0;
gs3 = 0;
gs4 = 0;
gs5 = 0;
}

void draw() {
background(155);
if (madeContact == false) {
delay(400);
port.write(65);
}


fill(gs1);
rect(0,400,100,100);
fill(gs2);
rect(100,400,100,100);
fill(gs3);
rect(200,400,100,100);
fill(gs4);
rect(300,400,100,100);
fill(gs5);
rect(400,400,100,100);


}


void serialEvent (Serial port) {
if (madeContact == false) {
madeContact = true;
}

serialInArray[serialCount] = port.read();
serialCount++;

if (serialCount > 4) {
gs1 = serialInArray[0];
gs2 = serialInArray[1];
gs3 = serialInArray[2];
gs4 = serialInArray[3];
gs5 = serialInArray[4];

println(gs1 + "\t" + gs2 + "\t" + gs3 + "\t" + gs4 + "\t" + gs5);

port.write(65);
serialCount = 0;
println();
}
}








-------------------------------------------------

// ARDUINO code - eddie_serial_cnr_photocells2.pdeeddie_serial_cnr_photocells4.pde
// this displays for 5 photocells.
// will work on one for 64.
// this is punctuation method, but isn't being really used as such?
// this will have to be turned into a proper array...

int sensor[4]; // array to hold the sensor values

void setup() {
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
if (Serial.available() > 0) {
int inByte = Serial.read();


// for loop to count from 0 to 2:4:
for (int i = 0; i < 5; i++) {
// read one of the sensors, divide by 4, put into the array:
sensor[i] = analogRead(i);analogRead(i)/4;
// if the value is 255, truncate it so we can use 255
// as a unique value to punctuate the sentence:
if (sensor[i] == 255) {
sensor[i] = 254;
}

// Serial.print("Sensor < 0 > is ");
Serial.print(sensor[0], DEC);BYTE);
// Serial.print('\t');

// Serial.print("Sensor < 1 > is ");
Serial.print(sensor[1], DEC);BYTE);
// Serial.print('\t');

// Serial.print("Sensor < 2 > is ");
Serial.print(sensor[2], DEC);BYTE);
// Serial.print('\t');

// Serial.print("Sensor < 3 > is ");
Serial.print(sensor[3], DEC);BYTE);
// Serial.print('\t');

// Serial.print("Sensor < 4 > is ");
Serial.print(sensor[4], DEC); Serial.print('\t'); Serial.println(); delay(150); // print the current sensor value:BYTE);
// String sens = "Sensor"; // String numb = (i,DEC); /* Serial.print(i, DEC); Serial.print( " is "); Serial.print(sensor[i], DEC); Serial.print('\t'); // Serial.println("Sensor"+ numb + " is " + Serial.print(sensor[i],DEC) ); Serial.print("STOP");

// if (i = 4) { // Serial.println();
// } */}// After printing the sensor values, print a 255://Serial.print(255, DEC);}delay(150);


-------------------------------------------------