Link to the above grasshopper definition: Temp_Input
import processing.serial.*;
Serial myPort;
import oscP5.*;
import netP5.*;
NetAddress myBroadcastLocation;
OscMessage myMessage;
OscP5 oscP5;
float inX;
float inY;
float inZ;
float inBend;
float inR;
float inG;
float inB;
float inT;
float inH;
float bX;
float bY;
float bZ;
int check = 0;
float sensors[];
int ch = 0;
String myString;
void setup() {
size(400,220);
oscP5 = new OscP5(this,6880);
myBroadcastLocation = new NetAddress("localhost",1220);
String portName = Serial.list()[2];
myPort = new Serial(this, portName, 9600);
myPort.bufferUntil('\n');
}
void draw() {
background(0);
noStroke();
myMessage = new OscMessage("/temp");
///background for graphs
fill(80);
rect(100,40,200,20);
rect(100,80,200,20);
textSize(12);
fill(255);
textAlign(RIGHT);
text("TEMPERATURE",90,55);
text("HUMIDITY",90,95);
/// 3 axis of the accelorometer
fill(0,255,255);
rect(100,40,inT,20);
rect(100,80,inH,20);
if(inX > 0 && check == 0){
bX = inX;
bY = inY;
bZ = inZ;
check = 1;
}
if (myString != null) {
myString = trim(myString);
float sensors[] = float(split(myString, ','));
inX=sensors[0];
inY=sensors[1];
inZ=sensors[2];
inBend=sensors[6];
inR=sensors[3];
inG=sensors[4];
inB=sensors[5];
inT=sensors[7];
inH=sensors[8];
}
float temp = map( inT, 30, 50, 0, PI/2 );
myMessage.add(temp);
oscP5.send(myMessage, myBroadcastLocation);
}
void serialEvent(Serial myPort) {
// read the serial buffer:
myString = myPort.readStringUntil('\n');
}