Stupid question I know, but please help

I use the new iMac M1 with Arduino Uno and I am an absolute beginner....

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Serial.print("Should only appear once");
}

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

OUTPUT ON THE MONITOR:
Should only appear onceShould only appear once

It prints twice ...
What am I missing ?
Thank you for your help.

Your board is resetting

Please remember to use code tags when posting code

1 Like

My guess is your Arduino resets for some reason.

I would change Serial.print to Serial.println to start a new line after the print. Switch on timestamp in the serial monitor. It will at least tell you how much time elapses between the two prints.

Press the reset button on the Uno and see if the same thing happens. If not then chances are it has to do with your Macs serial port or driver.
And you can add a delay(1000); before Serial.print just to see if that helps.

My 2 c to narrow down the causes.

1 Like

There is a buffer or restart or something. I have the same in linux. Someone explained it a few months ago, but I can't find that topic at the moment.
Press the reset button and it will only show once.
Upload a sketch, and you see it twice. I assume that this will be fixed in a future version of the Arduino IDE.

Some add a delay before Serial.print as Aggertroll wrote.

1 Like

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.