Problem - show values in window, read from Arduino.
in
Programming Questions
•
1 month ago
Hi.
I have a problem to show the values of Temperature in a window on Processing.
In Arduino i'm printing the code:
In Processing i'm saving the temperature to a notepad in this format:
I have a problem to show the values of Temperature in a window on Processing.
In Arduino i'm printing the code:
- Serial.print(tempC, 1);
Serial.print("\t");
Serial.print(tempK, 1);
Serial.print("\t");
Serial.print(tempF, 1);
In Processing i'm saving the temperature to a notepad in this format:
- 2013/8/28 16:31:52 25.6 298.7 78.1
- 2013/8/28 16:31:53 25.9 299.1 78.7
- 2013/8/28 16:31:54 25.9 299.1 78.6
But when i show the sensorReading in a Window, it's show like this:
- 25.9299.178.6
it's printing the temperature in Celsius, Kelvin and Fahrenheit bonded.
I'm using this code:
- import processing.serial.*;
Serial myPort;
String sensorReading="";
PFont font;
PrintWriter output;
void setup()
{
size(600, 300);
myPort = new Serial(this, "COM4", 9600);
myPort.bufferUntil('\n');
font = createFont(PFont.list()[4], 36);
textFont(font);
output = createWriter( "C:/Users/alunosdefi/Desktop/data.txt" );
}
void draw()
{
}
void serialEvent (Serial myPort)
{
sensorReading= myPort.readStringUntil('\n');
if(sensorReading != null)
{
sensorReading=trim(sensorReading);
}
output.println(year() + "/" + month() + "/" + day() + "\t" + hour() + ":" + minute() + ":" + second() + "\t" + sensorReading);
output.flush();
writeText("Temperatura: " + sensorReading + " ºC");
}
void writeText(String textToWrite)
{
background(180);
fill(127,0,0);
text(textToWrite, width/20, height/2);
}
Can someone tell me how I can only display temperature in ºC in the window?
thank you
1