Initial Program Load

I acquired a Nano 33 IoT and so far I'm impressed! My question is very much a new Arduino user related one.
How do you get the board to load the same program each time it powers up?
(Apologies - this might be handled somewhere else in the community but I'm new and don't have the terminology to enable a decent search :frowning:

Thanks

Shouldn't the question be "How do you stop it loading the same program?" :wink:

Thanks for your response…
No… I’m looking to create a version of the ESP8266 / Smoke Alarm project (which I’ve seen elsewhere on the web).
Basically, when the domestic smoke detector is triggered, I’ll get power from the pin that feeds the alarm sounder. This powers on the Nano and, if I can get the same program loaded each time it powers up, then I’ll be able to connect to wifi and send a relevant MQTT message … which can be used to drive a variety of actions etc etc

Doh! Forget I asked anything!!!
I checked my sketch (which connects to wifi and sends an MQTT message) and it was liberally splattered with serial statements. Removing these has enabled it to work. I guess my sketch was waiting for a non existent serial connection.
It now seems to work ok and I think I should be able to make my Smart Smoke Detector work too.

You'll often see something like this in Arduino sketches:

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

This will make your code stay in an infinite loop until the serial port is opened in Serial Monitor. The reason that is useful is because on native USB boards like the Nano 33 IoT, the board is not reset when you open the Serial Monitor. That means any serial output printed between the time the program starts running and you get the Serial Monitor open will be lost. If that's a problem, it's useful to make the program wait for the Serial Monitor before running. However, if you are wanting to run your program when the board is not connected to Serial Monitor, you must remove that while loop to allow it to run.