Samstag, 7. November 2009

blingblingsensor

//test with two photocells and a led
/*
the photocells are connected to analog 0 and 1;
and the led is connected to dgital port 13;
*/

import cc.arduino.*;
import processing.serial.*;

Arduino myArduino;

float value,valueb;
int count;
float x,y,dirx,diry,vorx,vory;


void setup() {
size(600,600);
myArduino = new Arduino(this, Arduino.list()[1], 57600);
background(100);
smooth();
count=0;
}

void draw(){
borders();
fill(100,80);
noStroke();
rect(0,0,width,height);
value=5*(myArduino.analogRead(0));
valueb=5*(myArduino.analogRead(1));
stroke(value,50,50);
strokeWeight(value/5);
noFill();
ellipse(mouseX,mouseY,value,value);
stroke(value-50,80,80);
noFill();
strokeWeight(valueb/5);

x=x+1;
y=y+1;

ellipse(mouseX,mouseY,valueb,valueb);

if ( (count% 100 >= 5) && (count% 100 <= 50) ) {
myArduino.digitalWrite(13, myArduino.HIGH);
}
else{
myArduino.digitalWrite(13, myArduino.LOW);
}

count++;
//saveFrame("anim/circles-####.png");
}

void borders() {
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x > width) x = 0;
if (y > height) y = 0;

}

Keine Kommentare:

Kommentar veröffentlichen