开发者

Using the serial monitor in the Arduino IDE (why is this working?)

开发者 https://www.devze.com 2023-01-26 16:48 出处:网络
I have a peculiar problem with writing to serial on an Arduino. I recently changed boards in a project from the Duemilanove to the Mega2560. Part of my code does very simple serial reading from a proc

I have a peculiar problem with writing to serial on an Arduino. I recently changed boards in a project from the Duemilanove to the Mega2560. Part of my code does very simple serial reading from a processing program, for example:

if (Serial.available() > 0) {
    byte c = Serial.read();
}

In the setup method I open a 115200 Baud connection with:

  Serial.begin(115200);

Anyhow, this worked fine with the Duemilanove but now that I switched to the Mega2560 the Arduino doesn't seem to be receiving serial data. However, to my amazement when I open the serial monitor window before launching the processing program that sends the data, all of the data is sent correctly.

My question is, what does the serial monitor change that makes everything work and how can I recreate that in m开发者_JAVA技巧y processing program?


The Arduino software reset means whenever a serial monitor is connected, the Arduino is auto-reset. Have you noticed this behavior and could this be the cause?

To turn off auto-reset there is a trace that can be cut. It is easy to resolder if you want to turn the feature back on.

This Arduino Wiki Page may be helpful.

Using the serial monitor in the Arduino IDE (why is this working?)


The serial monitor only does RESET to the board. Just try and reset the mega before you run your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消