import processing.serial.*; Serial myPort; 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(800,500); String portName = Serial.list()[2]; myPort = new Serial(this, portName, 9600); myPort.bufferUntil('\n'); } void draw() { background(inR/4,inG/4,inB/4); noStroke(); ///background for graphs fill(80); rect(100,40,200,20); rect(100,80,200,20); rect(100,120,200,20); textSize(12); fill(255); textAlign(RIGHT); text("PRESSURE 1",90,55); text("PRESSURE 2",90,95); text("PRESSURE 3",90,135); /// 3 axis of the accelorometer fill(0,255,255); rect(100,40,inR/5,20); rect(100,80,inG/5,20); rect(100,120,inB/5,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]; } } void serialEvent(Serial myPort) { // read the serial buffer: myString = myPort.readStringUntil('\n'); }