Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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