Hello,
In arduino I’m sending the following:
Serial.println(float(mlGeschonkenTotaal/1000),1);
This is a results in a number like 0.1 which increases which 0.1 over time.
In processing I would like to draw this number as text on the screen.
I can send the number but if I want to draw “L” behind the number the text string is shown over two lines whereas I would like it to be shown in one single line:
It starts correct but as soon as I start sending serial the L moves one line down.
Processing code:
// Example by Tom Igoe
import processing.serial.*;
long ontvangen = 0;
float LGedronken = 0;
float sensorValue;
Serial myPort; // The serial port
String inByte = "0.0";
void setup() {
fullScreen();
// List all the available serial ports
printArray(Serial.list());
// Open the port you are using at the rate you want:
String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 2000000);
}
void draw() {
while (myPort.available() > 0) {
inByte = myPort.readStringUntil('\n');
}
background(0, 0, 80);
fill(255);
textSize(100);
textAlign(CENTER);
text(inByte+" L", width/2, height/2);
textSize(60);
textAlign(CENTER);
text("Hello", width/2, height/2+100);
rectMode(CENTER);
rect(width/10, (height/10)*8, LGedronken, 55, 7);
}
The writing part of the variable is this part:
textSize(100);
textAlign(CENTER);
text(inByte+" L", width/2, height/2);
textSize(60);
textAlign(CENTER);
text("Hello", width/2, height/2+100);