Hello, I’m trying to print the serial value of my Arduino just above the rect and circle, but when the value changes there is a buildup of values so it looks blurry. any suggestions for me? Sorry, I’m just learning to use processing.
// test print angka dan rectangle
import processing.serial.*;
//float num= random(0, 50);
//float num1= random(0, 100);
Serial port;
void setup() {
background(0);
size(400, 400);
port = new Serial(this, "COM8", 9600);
rect(80, 80, 60, 60, 12);
rect(220, 80, 60, 60, 12);
ellipse(180, 200, 100, 100);
fill(0, 120, 255);
PFont f = createFont("Georgia", 70);
textFont(f);
textSize(15);
text("Ambient Temp(°C)", 60, 70);
text("Humidity(%)", 210, 70);
text("Load (Kg)", 150, 270);
}
void draw() {
// noStroke();
if (port.available() > 0) {
String val = port.readString();
String [] list = split(val, ',');
float temp = float(list[0]);
float hum = float(list[1]);
float load = float(list[2]);
fill(0, 120, 255);
textSize(15);
text(temp, 90, 115);
text(hum, 225, 115);
text(load, 150, 205);
}
}