+1 500 000 products in offer
6000 packages per day
+300 000 clients from 150 countries
The program running on the Arduino does not have a built-in "stop" function, as found in operating systems. This is because the Arduino runs in bare-metal mode, i.e. without a system layer to manage the lifecycle of the program. To stop it running, use one of the techniques of controlled main loop expiration or physical power interruption.
Every sketch (i.e. user program) on Arduino is based on two basic functions: setup() and loop(). The setup() function is executed only once after startup or reset, while loop() runs in an infinite loop, until power is lost. There is no function responsible for closing the programme, as the microcontroller does not use an operating system to control the states of the processes. For this reason, the classic approaches known from computers, i.e. closing the application or stopping it with a button, are not applicable in the context of the Arduino.
The simplest way to stop the program is to cut the power, which immediately stops the execution of all instructions. This can be done physically by unplugging the USB cable or turning off the external power source (e.g. a battery or DC power supply). When the power supply is reconnected, the microcontroller will automatically start executing the program from the beginning, from the setup() function. An alternative method is to upload an empty sketch, i.e. a program containing only the setup() and loop() functions without any internal logic. Such a sketch formally works, but in practice it does not perform any operations, which from the user's point of view can be seen as stopping the program. In more advanced applications, the microcontroller can be programmed to enter an infinite passive loop, e.g. while(true){} without any instructions inside. Such code makes the microcontroller 'stuck' in one place, stopping responding to inputs or generating outputs. Still another solution is to put the microcontroller into sleep mode, which involves deactivating the main computing blocks and entering a minimal power-down state. In power-down mode, the chip stops all processes until externally woken up, e.g. via a hardware interrupt. Sleep modes are particularly useful in battery-powered designs where reducing power consumption is important.
It is important to note that each of the methods described has its own consequences. Cutting off the power interrupts the work immediately, but does not allow any transient data to be saved. Uploading an empty sketch or stopping a programme in an infinite loop does not shut down the chip - the power supply is still active and the microcontroller is drawing power. Sleep modes require additional configuration and careful thought about how and when the chip should be woken up. The program on the Arduino does not stop by itself, but runs continuously from the moment it starts up until the power is cut off. To get it to stop, you can use techniques such as uploading an empty sketch, entering an infinite loop, using sleep mode or simply physically turning off the power. The choice of method depends on the context of the project and the expected end results.
Resetting the microcontroller in the Arduino does not stop the program - it simply restarts it. This means that the setup() function is executed from scratch, and then the program immediately goes to the loop() function, where it runs in an infinite loop again. Therefore, reset is not a method of stopping the program, but of "restarting" it.
When the RESET button is pressed (or a low logic state is given to the RESET pin), the microcontroller restarts as if it has just been powered up. In practice, this means that:
A program stop is a permanent or temporary halt in program operation, e.g. waiting for a condition to occur or a complete extinguishing of microcontroller activity (as in power-down mode). A reset, on the other hand, is an active start of everything from the beginning, not a withdrawal of activity. In a nutshell: Reset = start the program again Stop = pause or end the program
Transfer Multisort Elektronik (TME) is one of the world’s largest global distributors of electronic components, electrotechnical parts, workshop equipment, and industrial automation. The catalog includes over 1,500,000 products from 1,300 leading manufacturers. TME’s modern logistics centers in Łódź and Rzgów (Poland), with a combined area of over 40,000 m², ship nearly 6,000 packages daily to customers in more than 150 countries.
TME also invests in the development of knowledge and skills of young engineers and electronics enthusiasts through the TME Education project, and supports the tech community by organizing the TechMasterEvent series, promoting innovation and experience exchange.