Stop and/or clear

Is there a way to stop a program running on the Arduino UNO or to clear a program from memory once it is loaded?

You cannot stop a program, but can get the same effect by having your code run into a tight loop:

void loop() {


if (finished_doing_stuff) { while(1); // not getting out of this loop. }


Or, if you really only want a single shot, leave the loop empty (nothing in it at all), and do all your code in the setup() function.

Could you explain why your application needs to stop the program?

There is no need to clear a program - just load another one. Loading a sketch will always overwrite the old sketch. If you have a programmer, you can clear the chip entirely, or reload the bootloader. Perhaps you would explain why you need to do this?