Sketch "clean up" needed when changing circuit?

Hi,

I'm very new to the whole Arduino world, as its currently my third day. I'm currently doing the projects in the starter kit and have a question when going from one project to another.

So let's say the Arduino has a Sketch programmed. Now you unplug it and change the connected circuit and also program a new Sketch fitting to the circuit change. In order to get my sketch on the Arduino I need to connect it again, but then the old program kicks in. What happens if the old program somehow "clashes" with the now new circuit? For example a pin is supposed to be an input pin, but now its still outputting because of the old program?

As I said I'm really new to this but for me this sounds like a possible source of error that could lead to unexpected currents flowing in my new circuit or even shortcuts because of an old program.

Hope someone can enlighten me. Thanks in advance.

It really depends on the circuit. With certain circuits, it could damage the Arduino, the components in the circuit, or even the people nearby.

This is unlikely to be an issue - but it is conceivable you could damage the Arduino. ( e.g shorting out a digital input still connected to a switch that becomes an output)
it is good practice to disconnect anything connected to the pins before uploading a new sketch . You can then power down and add the external components and power up.

If you were to “park up “ your Arduino , you could, if you want, just upload a blank sketch ( the sketch you see when you open a “new” sketch from the IDE) , so next use you can be sure it’s ok to go .

So .....if say you had the blink sketch installed and you’ve then wired up the nuclear missile trigger , then you dont accidentally fire it off whilst uploading the new sketch.