Hello, I am trying to place text inside the second window of my code, but I'm struggling to figure out how and where in the code to place it. Please help!
I am creating a GUI to test machine equipment. The problem I need help with is when I click button 1, it disables button 2. Is there something I am missing? Thank you for your help!
while (port.available() > 0) { //as long as there is data coming from serial port, read it and store it
serial = port.readStringUntil(end);
if (serial != null) { //if the string is not empty, print the following
currentTime = millis();
if(currentTime - timeold >= interval){
String[] a = split(serial, ','); //a new array (called 'a') that stores values into separate cells (separated by commas specified in your Arduino program)
print(timeold);
print(" ");
print(a[0]);
print(a[1]);
print(a[2]);
//send data to .csv file
output.print(timeold); //print time
output.print(",");
output.print(a[0]); //print temp1
output.print(",");
output.print(a[1]); //print temp2
output.print(",");
output.print(a[2]); //print RPM
timeold = millis();
}
}
}
}
output.flush(); // Writes the remaining data to the file
I am trying to get my Arduino Uno to read multiple temperature sensors. I have it reading one and and outputting the time, but the second sensor keeps reading 0.00. The code is below. I have no idea why this is happening. I would appreciate any help. Thank you!
Sample Output:
1.425
24.31 0.00
2.676
24.31 0.00
3.943
24.25 0.00
5.176
24.31 0.00
6.426
24.31 0.00
7.693
24.31 0.00
8.927
24.31 0.00
10.177
24.31 0.00
11.427
24.31 0.00
12.678
24.31 0.00
13.928
24.31 0.00
15.178
24.31 0.00
16.428
24.31 0.00
17.678
24.31 0.00
18.928
24.31 0.00
20.162
24.31 0.00
21.412
24.31 0.00
import processing.serial.*;
PFont myFont; // The display font:
String inString; // Input string from serial port:
int lf = 10; // ASCII linefeed
PrintWriter output;
DateFormat fnameFormat= new SimpleDateFormat("yyMMdd_HHmm");
DateFormat timeFormat = new SimpleDateFormat("hh:mm:ss");
String fileName;
Serial myPort; // Create object from Serial class
short portIndex = 0; // select the com port, 0 is the first port;
long timeold = 0;
int interval = 500;
int linefeed = 10; // Linefeed in ASCII
void setup()
{
// Open whatever serial port is connected to Arduino.
String portName = Serial.list()[portIndex];
println(Serial.list());
println(" Connecting to -> " + Serial.list()[portIndex]);
myPort = new Serial(this, portName, 9600);
Date now = new Date();
fileName = fnameFormat.format(now);
output = createWriter(fileName + ".csv"); // save the file in the sketch folder
background(50);
myPort.bufferUntil(linefeed);
}
void draw()
{
int val;
String time;
while ( myPort.available() >= 15) // wait for the entire message to arrive
{
long currentTime = millis();
if(currentTime - timeold > interval) {
String inString = myPort.readStringUntil('\n');
String[] words = split(inString, '\t');
String temp = words[0];
println(temp);
output.print(currentTime / 1000.0);
output.print(", ");
output.println(temp);
}
}
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file