我想做的是这个;我想运行下面的处理代码,2分钟后它应该自动停止并让自己再次运行,并在2分钟后一次又一次地停止。我的意思是我不想通过手动单击运行按钮来运行代码。
我是处理初学者,如果你能回答,我会很高兴我非常需要这个。
import processing.serial.*;
// The serial port:
Serial myPort;
String dataReading = "";
String [] dataOutput = {};
void setup() {
size(500,500);
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[7], 9600);
//in my case,the Serial port the Arduino is connected to is 9th on the serial list, hence the [8]
//to get access to the serial list you can use >> println(Serial.list());
myPort.bufferUntil('\n');
}
void draw() {
//...
}
void serialEvent(Serial myPort) {
dataReading = myPort.readString();
if(dataReading!=null){
dataOutput = append(dataOutput, dataReading);
saveData();
}
}
void saveData() {
println("saving to txt file...");
saveStrings("data/data.txt", dataOutput);
}