0

So today I started to learn Arduino uno. I have an LM35 temperature sensor and I got what I needed from it. Now it's just keep calculating till I plug it off.

I know there is a reset button. When I press it or hold it, it's closing and opening again to do the coding again. I want it to completely stop. Like when I first plug led was flashing to show arduino is connected.

And I know I can just upload another code. But I don't want that.

If it's possible please let me know.

0

Actually, it already did something when you turned it on when you got it: it was blinking a LED. It did not mean it was connected. A microcontroller (or controller) always does something. Although you can consider an empty endless loop as 'nothing'.

And now you overwritten that sketch with your LM35 sketch.

However, you can put the Blink sketch again in your Arduino, and it can be found here:

https://www.arduino.cc/en/Tutorial/Blink

You don't need to connect the LED, it will use the built in LED.

If you don't want the Arduino to do anything, just switch it off (disconnect the power).

| improve this answer | |
1

When a microcontroller or a computer is powered on, it always does something. A program on a computer will return and the OS will run again. On a microcontroller there is no OS to return to, so every microcontroller program has an infinite loop.

The void loop() function of the Arduino framework is such an infinite loop. If you want your LM35 temperature code to be only run once, you can put it into the void setup() function, which is run once before going to loop(). When the loop() function is empty, the Arduino will do nothing after it returned from setup().

Otherwise, if you want to put your code into loop() for whatever reason, you can insert an infinite loop whereever you want it:

while(true);

This loops forever and does nothing. Your temperature code will only be executed on the next reset or power on.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.