import processing.serial.*;
import nl.tue.id.oocsi.*;
OOCSI oocsi;
Serial myPort; // we're calling the port "myPort"
String dataReading = "";
int x; // this is val1 on the Arduino
int y;
int z;
void setup() {
size(500,500); // size of the window
myPort = new Serial(this, Serial.list()[0], 115200); // reading it right
myPort.bufferUntil('\n'); // goes on until manual stop
oocsi = new OOCSI(this, "thanos", "diserver.id.tue.nl");
}
void draw() {
background(255);
noStroke();
fill(255,0,0,90);
rect(30,0,30,x);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot",45,160);
text(x, 45, 180);
noStroke();
fill(0,255,0,90);
rect(100,0,30,y);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot2",115,160);
text(y,115,180);
noStroke();
fill(0,0,255,90);
rect(180,0,30,z);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot3",195,160);
text(z,195,180);
oocsi
.channel("thanothijs")
.data("softpot", x)
.data("softpot2", y)
.send();
}
void serialEvent(Serial myPort) {
try {
dataReading = myPort.readString();
if(dataReading!=null) {
String[] trim = split(dataReading,'>');
String[] pieces = split(trim[0], ';');
x = parseInt(pieces[0]);
y = parseInt(pieces[1]);
z = parseInt(pieces[2]);
}
}
catch (Exception e){
println("Error");
}
}
import nl.tue.id.oocsi.*;
OOCSI oocsi;
Serial myPort; // we're calling the port "myPort"
String dataReading = "";
int x; // this is val1 on the Arduino
int y;
int z;
void setup() {
size(500,500); // size of the window
myPort = new Serial(this, Serial.list()[0], 115200); // reading it right
myPort.bufferUntil('\n'); // goes on until manual stop
oocsi = new OOCSI(this, "thanos", "diserver.id.tue.nl");
}
void draw() {
background(255);
noStroke();
fill(255,0,0,90);
rect(30,0,30,x);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot",45,160);
text(x, 45, 180);
noStroke();
fill(0,255,0,90);
rect(100,0,30,y);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot2",115,160);
text(y,115,180);
noStroke();
fill(0,0,255,90);
rect(180,0,30,z);
fill(0);
textAlign(CENTER, BOTTOM);
text("softpot3",195,160);
text(z,195,180);
oocsi
.channel("thanothijs")
.data("softpot", x)
.data("softpot2", y)
.send();
}
void serialEvent(Serial myPort) {
try {
dataReading = myPort.readString();
if(dataReading!=null) {
String[] trim = split(dataReading,'>');
String[] pieces = split(trim[0], ';');
x = parseInt(pieces[0]);
y = parseInt(pieces[1]);
z = parseInt(pieces[2]);
}
}
catch (Exception e){
println("Error");
}
}
No comments:
Post a Comment