Pages: [1]   Go Down
Author Topic: Maybe a stupid question, but how to you prevent old code from running...  (Read 207 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just got my Arduino in today, very excited. I'm a few lessons in now, but I have a question...

If I setup code for a circuit, upload it, then I disconnect the arduino and start a new circuit... how do I upload the new code for the new circuit without the old code automatically running? Couldn't I risk screwing something up by letting old code run on a new circuit?
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 114
Posts: 4961
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a number of threads that suggest you may be right.

So what you could do is:

  • Power Arduino down
  • Dismantle old circuit
  • Power up, old sketch runs but no circuit attached
  • Load Bare Minimum sketch (empty setup() & loop()- File > Examples > 01 Basics)
  • Power down
  • Mantle* new circuit
  • Power up (Bare Minimum runs)
  • Load new sketch

*Well, if dismantle means take something apart, mantle must mean build it in the first place?
« Last Edit: July 24, 2014, 09:15:57 pm by JimboZA » Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makes sense. Thank you. Is that the standard procedure then? Just wanting to get things right from the get go.
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 114
Posts: 4961
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure if it's standard or not... standard (as in most common) is probably to build the new circuit under power and risk shorting something.

I think there's even been a suggestion to load BareMinimum when you've finished playing: that way next time you power up, the board's in a known condition, especially if you have many boards and just grab one.

Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Correct me if I'm wrong,
Assuming you're running a relativly stock arduino without sd card reader or other storage,
when you upload the next sketch/program into the arduino the previous one gets erased from the arduino.
The memory it is stored in is non volitile (does not wipe as soon as power is lost) memory..
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 114
Posts: 4961
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Correct me if I'm wrong,
Assuming you're running a relativly stock arduino without sd card reader or other storage,
when you upload the next sketch/program into the arduino the previous one gets erased from the arduino.
The memory it is stored in is non volitile (does not wipe as soon as power is lost) memory..

True but that's not what the OP's asking. His concern is that if he builds circuit B and powers up, the old sketch for circuit A will run before he loads the new sketch for circuit B, and that could have consequences.
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I always upload the new code before attaching the new software.

The other way of doing it would be to power up with the reset held down, then only release the reset when you get the message from the IDE that you are downloading code.
Logged

Pages: [1]   Go Up
Jump to: