Using a serial monitor in an Arduino IDE (why does it work?)

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

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

In the installation method, I open the 115200 Baud connection with:

  Serial.begin(115200);

Anyway, this worked fine with Duemilanove, but now that I switched to Mega2560, the Arduino does not seem to be receiving serial data. However, to my surprise, when I open the serial monitor window before running a processing program that sends data, all data is sent correctly.

My question is: what will change a serial monitor that makes everything work and how can I recreate it in my processing program?

+3
source share
2 answers

Arduino reset software means that whenever a serial monitor is connected, Arduino will automatically reset. Have you noticed this behavior and this may be the reason?

To disable auto-reset, you can cut the trace. If you want to turn this feature back on, you can easily recognize it.

This Arduino Wiki Page may be helpful.

S

+1
source

RESET . RESET , .

0

Source: https://habr.com/ru/post/1776012/


All Articles