import controlP5.*; import processing.serial.*; ControlP5 cp5; Serial port; int myColorBackground = color(0,0,0); int knobValue = 100; int tempValue = 1; Knob myKnobA; Knob myKnobB; String reading = "no reading yet"; void setup() { size(700,500); smooth(); noStroke(); cp5 = new ControlP5(this); println(Serial.list()); String[] strs = Serial.list(); port = new Serial(this, strs[1], 9600); myKnobA = cp5.addKnob("temp") .setRange(1800,2200) .setValue(1850) .setPosition(100,50) .setRadius(50) .setDragDirection(Knob.VERTICAL) ; } void draw() { background(myColorBackground); fill(255); String listen = port.readString(); if (listen != null) { reading = listen; } println(reading); textSize(32); text(reading, 300, 100); pushMatrix(); translate(200, 400); beginShape(); noFill(); stroke(255); for (int i = 500; i < 1400; i = i+1){ curveVertex((i - 500)/3, -(-1.729 + 4560/(i - 240.8))*10); } endShape(); beginShape(); stroke(205, 100, 0); line(((tempValue-32)/1.8 - 500)/3, -(-1.729 + 4560/((tempValue-32)/1.8 - 240.8)*10 -40),((tempValue-32)/1.8 - 500)/3, -(-1.729 + 4560/((tempValue-32)/1.8 - 240.8)*10+ 10)); endShape(); for (int i = 0; i < 130; i = i + 20){ textSize(9); text(i/10, -20, - i - 30); stroke(255); line(-5, - i -33, 0, -i - 33); } rotate(-PI/2); textSize(12); text("log (viscosity)", 40, -25); popMatrix(); } public void temp(int theValue) { // myColorBackground = color(theValue); port.write(theValue); tempValue = theValue; } public void SerialEvent(Serial myPort){ String myString = myPort.readString(); if (myString != null){ println(myString); } } void keyPressed() { switch(key) { case('1'):myKnobA.setValue(180);break; case('2'):myKnobB.setConstrained(false).hideTickMarks().snapToTickMarks(false);break; case('3'):myKnobA.shuffle();myKnobB.shuffle();break; } }