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?

asked Oct 12, 2012 at 1:05
\$\endgroup\$

1 Answer 1

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.

answered Oct 12, 2012 at 1:38
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.