有没有办法通过Java中的USB输出布尔值



我正在为我的第二年项目进行模拟,该项目需要通过USB输出布尔值到Arduino。我想知道最好的方法是什么,如果我需要使用图书馆或其他东西?我正在使用Java。任何帮助将不胜感激,谢谢!

许多Arduinos具有USB串行端口,因此使用USB上的端口 - 示例只需更改每秒发送的布尔值。

int bool_val = 0;
void setup() {
 // initialize the serial communication:
 Serial.begin(9600);
}
void loop() {
  // send the value
  Serial.println(bool_val);
  delay(1000);
  // toggle value
  bool_val = !bool_val;
}

然后,您可以打开从Arduino连接的USB的序列,以使用RXTX之类的内容读取Java代码中的值http://users.frii.com/jarvi/rxtx/

最新更新