Hi,
I'm new to Arduino. I'm using the Uno and IDE 1.0.5 to program and download.
Each time when I download a program it starts running then it is aborted and started again.
In my program I print some strings to the Serial Monitor. After download I see a few strings in the Monitor, then I see
the first strings again (indication that program is restarted), and it will run to the end (printing all the strings).
How can i make sure the program is nicely started only once?
spycatcher2k:
Read the stickies and then POST YOUR CODE
Sorry, I was thinking this problem is not related to specific code. But here it is:
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// send
Serial.println("\nString 11111111111111111111111111111111111111111");
Serial.println("\nString 22222222222222222222222222222222222222222");
Serial.println("\nString 33333333333333333333333333333333333333333");
Serial.println("\nString 44444444444444444444444444444444444444444");
Serial.println("\nString 55555555555555555555555555555555555555555");
Serial.println("\nString 66666666666666666666666666666666666666666");
Serial.println("\nString 77777777777777777777777777777777777777777");
Serial.println("\nString 88888888888888888888888888888888888888888");
Serial.println("\nString 99999999999999999999999999999999999999999");
}
void loop() {
}
After downloading the program, it probably automatically starts the program.
When I wait a long time before opening the Serial Monitor. I initially see first this on the Serial Monitor:
Thus it seems that when running the first time (immediately after download) some serial information is lost.
And when opening the Serial Monitor the program is running again.
Can I somehow disable the automatic run after download? And only run when opening the Serial Monitor?
That would give me a nice clean start of the program.
mechamania:
So it would be much cleaner to keep the Serial Monitor open when downloading.
That's not how Serial works. One device at a time.
A simple 2-5 second wait at the start of the program would be one way. Another is to sit in this loop right after Serial.begin. Then use the Serial monitor (once connected) to send a single character (w/ LF and CR turned off)