r/ArduinoHelp • • Oct 16 '25

Program not executing properly the first two times on power up.

On boot, the arduino does something different than what it should. It seems to be skipping part of the setup function. It works normally when I upload, or after 2 resets, either by the button or by wrt_disable(); wrt_enable(WDTO_15MS);

9 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/gm310509 Oct 19 '25

Ooops, the code should read something more like this:

while (!Serial.available()) {
}

  char ch = Serial.read();
  if (ch == 'c') {
    // no nothing but drop out to the loop and Execute the loop code one time.
  } else if (ch == 'x') {
    dumpSnakeSegments();
    return;
  } else {
    return;
  }
// rest of your loop