我想從Arduino讀取數據。我的Arduino的鱈魚是簡單將數據從Arduino中讀取到處理中返回null結果
void setup()
{
//initialize serial communications at a 9600 baud rate
Serial.begin(9600);
}
void loop()
{
//send 'Hello, world!' over the serial port
Serial.println("Hello, world!");
//wait 100 milliseconds so we don't drive ourselves crazy
delay(100);
}
在處理我有以下鱈
import processing.serial.*;
Serial myPort;
String val;
void setup() {
String portName = Serial.list()[1];
myPort = new Serial(this, portName, 9600);
}
void draw() {
if (myPort.available() > 0)
{ // If data is available,
val = myPort.readStringUntil('\n');
}
println(val); //pr
}
但
VAL
始終是零。我不明白爲什麼每次都返回這個價值。該端口可用