2
\$\begingroup\$

Incoming Noob question alert!

So, I am new to this platform and I have a few questions.

  1. What happens when I upload a new sketch to the Arduino from the Arduino IDE, the older sketch gets deleted? or older one still survives in the Arduino memory somehow? if it does.. what happens when it runs out of memory? and how do you go about choosing which one to run?I have a feeling that the old one gets deleted, but I want someone to confirm it.

  2. I understand that the there is a void setup () part and void loop () part, the void loop part keeps the thing going indefinitely. Regardless, is there a way to start/stop the program? without cutting the power to the board?

\$\endgroup\$
5
\$\begingroup\$

Noob questions most welcome!

  1. The old program is erased, and a new one written.

  2. To pause the program, you could try sending the Arduino to sleep, but then you would need an interrupt to wake it up again and resume processing. You could also put the Arduino into a another loop waiting for an input to continue.

e.g.

while(1) {
    delay(100);
    if (digitalRead(2,LOW)) break;
}

This will keep the program stuck in the while loop until pin 2 is brought low (checking every 100ms). Make sure to set pin 2 to an input pin in setup(), e.g.:

pinMode(2,INPUT);

The difference between putting the Arduino to sleep and putting it in a loop is that sleep mode consumes less power.

\$\endgroup\$

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.