0
votes

I know this sounds really silly, but I really can't figure it out. I'm loading the following arduino code on an arduino uno:

void setup() {
    Serial.begin(9600);
    Serial.println("HELLO");
}

void loop() {
// put your main code here, to run repeatedly:
}

I'm uploading the code on the board and if I open a serial monitor repeatedly, I get different outputs. I'm expecting the output HELLO, and I get that sometimes. But I also get outputs like: HELLHELLO or HHELLO. I also loaded the same code on an arduino nano and it behaves similar.

Can someone please explain why this is happening? Is this an issue?

2

2 Answers

1
votes

This could be due to the usb to serial buffer still containing data from the previous reset.

Try storing the string in PROGMEM to keep the string in flash memory rather than in RAM and see if that helps.

1
votes

You need to set the baud rate to match to 9600 in the serial monitor, mismatched rates can cause unexpected output like you saw.

enter image description here