我正在尝试使用 arduino ide 和 processing ide 制作一个 arduino 项目。我开始做一个简单的测试来查看使用 arduino ide 显示数字 0,1..9 的环境,但是处理 ide 由于某种原因不能正确读取它,我不知道为什么,它读取的数字很奇怪从 10、13、53 等系列开始(只有这些数字,没有任何变化)。这是我的处理代码:
import processing.serial.*;
Serial port;
void setup() {
port = new Serial(this,"/dev/ttyUSB0",9600);
}
void draw() {
if(port.available() > 0) {
int info = port.read();
println(info);
println("===");
}
}
这是我的arduino代码:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int deg = 0;
int data = 1;
for (deg = 0; deg < 10; deg++) {
Serial.println(deg);
delay(15);
delay(1000);
}
}
此外,板和处理使用相同的端口/dev/ttyUSB0。我在 Ubuntu 20.04 上运行所有这些。我试图在谷歌上看,但似乎找不到任何东西。在此先感谢,欢迎任何提示。