Stopping Sketch

Basically I am going to use arduino uno and relay boards to control 3 pneumatic 24v solonoids.
This will be on a continous loop.
The qustion is if at anytime i wish to stop program running? Is it a simple matter of switching off arduino and restarting when its required.
This will be used on an old cable cutting machine i am trying to get running, the reels of cable are 100m so at the end of each reel i will need to stop and refeed new reel into machine.


You could do that. Or wire a button up, when pressed stops, when pressed again starts.

In general, processors run continuously. That's why most Arduino sketches have a main loop(). On a regular computer, the program/application may not run a continuous loop but the operating system is always looping (reading the keyboard & mouse, etc.). And, most GUI applications do run in a loop.

You can [u]sleep[/u] or [u]idle[/u] the processor.

Or you can put it into a "do nothing" [u]while() loop[/u] that loops "while" a button is not pushed, or until reset/power cycled. Or, you can do something similar with an if-statement in your main loop(), so your main loop() doesn't do much under certain conditions.

There is a C/C++ [u]exit()[/u] function. On a "regular computer" it stops the program and returns to the operating system. On the Arduino it "permanently" runs an infinite do-nothing loop that you can only break out of by powering-down or resetting the processor.