//CODEThis is a featured page



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

// 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_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 4:
for (int i = 0; i < 5; i++) {
// read one of the sensors, divide by 4, put into the array:
sensor[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], BYTE);
// Serial.print('\t');

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

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

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

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

// Serial.println();
delay(150);


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




No user avatar
little_ms_chewbacca
Latest page update: made by little_ms_chewbacca , Nov 18 2007, 10:00 PM EST (about this update About This Update little_ms_chewbacca Edited by little_ms_chewbacca

50 words added
68 words deleted

view changes

- complete history)
Keyword tags: code page
More Info: links to this page
Started By Thread Subject Replies Last Post
not_my_balls I FOUND OUR CODE ONLINE 0 Nov 18 2007, 3:44 PM EST by not_my_balls
Thread started: Nov 18 2007, 3:44 PM EST  Watch


arduino:

/* ReadMultiplexedSensorsAndSendMIDI
* ------------
*
* Reads 4 16 channel Multiplexers and sends the values
*
* Created 12 December 2005
* copyleft 2005 Stephen Williams <http://fluidforms.at> <http://algodes.com>
*
*/

#define CONTROLpin1 2
#define CONTROLpin2 3
#define CONTROLpin3 4
#define CONTROLpin4 5

// Variables:
char sensorValueToSend = 0; // Value of the sensor
int actualSensorValue = 0; // value from the analog input

// Some error chacking would be good here.
//If the values exceede 128 the will not fit in one byte.
void sendCommand(char command, char sensorID, char value) {
serialWrite(command);
serialWrite(sensorID);
serialWrite(value);
}


void setup() {
// set the states of the I/O pins:
pinMode(LEDpin, OUTPUT);
pinMode(CONTROLpin1, OUTPUT);
pinMode(CONTROLpin2, OUTPUT);
pinMode(CONTROLpin3, OUTPUT);
pinMode(CONTROLpin4, OUTPUT);

beginSerial(19200);
}


void loop() {
int i;
int j;
for (i=0; i <16; i++) {

// set control pins on the multiplexers
digitalWrite(CONTROLpin1, (i&15)>>3);//bit4
digitalWrite(CONTROLpin2, (i&7)>>2);//bit3
digitalWrite(CONTROLpin3, (i&3)>>1);//bit2
digitalWrite(CONTROLpin4, (i&1) );//bit1

// read the analogue inputs and send the values of the sensors.
for(j=0; j<4; j++){
actualSensorValue = analogRead(j);
// You will have to adjust this line so that can send the
// sensor value in one byte.
sensorValueToSend = actualSensorValue / 15;
sendCommand(0x90, i+16*j, sensorValueToSend);
}
// if you uncomment this line you can check the control pins
// of the multiplexers with your multimeter.
//delay(500);
}
}


Do you find this valuable?    
Keyword tags: code page
Showing 1 of 1 threads for this page

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)