Using multiple Mega controllers on a large model railway

No. The program you write exists as one or more text files on your PC. The IDE invokes a compiler for you to translate your code into binary and sends it to the Arduino.

That binary code will persist on the Arduino until you overwrite it and will survive power cycling.

Be aware though that any data that your program has gathered by reading sensors will vanish when the power is lost. For example, if the Arduino saw a sensor at the entry to a siding indicate that rolling stock went in, that knowledge will be lost when it is switched off. EEPROM or FRAM or SD cards are ways to ensure that that information is retained.

1 Like