SerialSocketEvent没有发射 [英] SerialSocketEvent not firing
问题描述
我抄这个code: http://playground.arduino.cc/Interfacing/Java 来一个java项目,我想这一点:
I have copied this code:http://playground.arduino.cc/Interfacing/Java to a java project, and i tried this:
void setup(){
Serial.begin(9600);
while(!Serial);
}
void loop(){
Serial.println("Test");
}
在我的Arduino UNO,具有很大的成绩,但是当我试图在我的esplora,该计划甚至没有火的Java项目中的事件监听器。
on my arduino UNO, with great results, but when i tried it on my esplora, the program did not even fire the event listener for the java project.
推荐答案
这是Esplora和莱昂纳多(都使用ATmega32u4)要求你要等到CDC串行已准备就绪。欧诺有一个专门的Atmega8 / 16u2控制串口/ USB通讯科。
An Esplora and leonardo (both use ATmega32u4) require you to wait until the cdc serial is ready. The Uno has a dedicated Atmega8/16u2 controlling the Serial/USB comms.
在您的code,你的 Serial.begin()
调用后,添加一个循环等待,直到准备:
In your code, after your Serial.begin()
call, add a loop to wait until ready:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
干杯
这篇关于SerialSocketEvent没有发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!