A newbie who doesnt want to break his new arduino uno

Hello everyone!

Im getting my first ever arduino tomorrow. Im pretty excited about it and been watching lots of tutorials from youtube etc.

But then i came to up to something i couldnt find an answer to.

Suppose i make a circuit to my breadboard and upload my sketch in my arduino. Everything is working well. Then i want to make an another project. I disconnect the arduino board from my pc to get the power out. Then i remove the components from the breadboard. After that i will put my new projects circuit on the breadboard and make my sketch at the arduino software. I plug the board to my pc via the usb for e upload. Now what happens: arduinoboard gets power and starts to go throu my last projects software which is planned for the previous circuit and not intended for the current one.

Is there a change something could break before i get my current sketch uploaded.

Im going to use the arduino uno. (r3 i think...).

Thanks for the help in advance... Cant wait for tomorrow.

I have never had a problem with this, but for absolute safety, I would say the simple solution is to download the new sketch before you hook anything up to your Arduino.

houpsi: Is there a change something could break before i get my current sketch uploaded.

Yes it is possible. There are lots of combinations where a pin could be configured one way in the old sketch and not configured the same way in your new sketch.

As kd7eir says, you should reprogram the board before attaching the new hardware. This is a good common sense step anyway. If you take a moment to plan out the hardware and software before diving in, you'll realize the board needs to be reprogrammed anyway.

The worst time to pick which pins you are going to use are a few seconds before you apply power.

Another good practice is reprogramming the board with Blink or no sketch at all. Before I start every project, I flash with Blink before connecting to any hardware.

houpsi: Hello everyone!

Im getting my first ever arduino tomorrow. Im pretty excited about it and been watching lots of tutorials from youtube etc.

But then i came to up to something i couldnt find an answer to.

Suppose i make a circuit to my breadboard and upload my sketch in my arduino. Everything is working well. Then i want to make an another project. I disconnect the arduino board from my pc to get the power out. Then i remove the components from the breadboard. After that i will put my new projects circuit on the breadboard and make my sketch at the arduino software. I plug the board to my pc via the usb for e upload. Now what happens: arduinoboard gets power and starts to go throu my last projects software which is planned for the previous circuit and not intended for the current one.

Is there a change something could break before i get my current sketch uploaded.

Im going to use the arduino uno. (r3 i think...).

Thanks for the help in advance... Cant wait for tomorrow.

Actually that is a very good question, especially from a beginner. There are two issues that can bite you and possibly cause damage to your arduino is such a situation.

  1. If your external circuit is externally powered rather then getting it's power from the arduino, and you then power off the arduino board but the external circuit still has power and wired to arduino I/O pins there is a risk from current trying to flow back through through the arduino I/O pins. In such a case one should always remove power from the external circuitry first before powering off the arduino.

  2. In cases where there is external circuitry wired to a arduino is not proper for the sketch that will be running when you start up the arduino there is risk to I/O pin damage depending on the external circuitry and the mode of the arduino I/O pins. There is an example sketch in the arduino IDE called BareMinimum that if loaded into the chip will insure that all arduino I/O pins are input mode only, thus not likely to have any effect nor be effected by external circuitry.

BareMinimum

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly: 
  
}

Lefty

You could also add a wire (or switch) to keep reset low until you are ready to start downloading. Remove the wire when the IDE shows "Compiled xxx of 32xxx bytes".

CrossRoads: You could also add a wire (or switch) to keep reset low until you are ready to start downloading. Remove the wire when the IDE shows "Compiled xxx of 32xxx bytes".

I'd say that method is not good enough and is fraught with potential peril as with that method, depending on the exact timing of the wire pull and when avrdude finally gets a chance to run, it could still be possible for the processor to take off from the bootloader and be into the user's sketch before avrdude has a chance to put the AVR back into the bootloader for downloading.

If the previous circuit used a pin as an output and the new circuit used the pin as an input, depending on the code and the circuit design there could be short between the pin and ground when the pin is being held high.

An example worst case would be that the old code was immediate turning on an LED by setting a pin high, and the new circuit design is using the pin as an input with a normally closed button.

As soon as the code starts running you have a dead short on a output pin that is being driven high. Not sure how long the pin will last under those conditions.

There is also the case where the pin is still an output but is controlling something external to the Arduino. For example, a motor or a relay that controls something else. While there wouldn't be any damage to the Aduino in this case, it may cause damage to something else as old code may cause something unexpected to activate on the new circuitry.

An easy thing to do is burn the blink demo sketch before hooking up the new circuit just to ensure that the old code is gone. That way you know it is gone and the only potential issue is the pin used for the LED.

--- bill

So the best way not to screw things up is?:

When starting to make a new project take the power out. Remove external components from arduino. Power it up again and upload the blink sketch (to easily get the io pins inputs, excluding 13). Power out. Make your new sketch and external circuitry without connecting the circuitry to arduino. Power up and upload the skecth. Power down and introduce the external circuitry. Power up and we have a working project without breaking our arduino.

Just Making sure i got things right :) and thanks for the good answers. Getting my arduino today, so im pretty psyched!

houpsi: So the best way not to screw things up is?:

When starting to make a new project take the power out. Remove external components from arduino. Power it up again and upload the blink sketch (to easily get the io pins inputs, excluding 13). Power out. Make your new sketch and external circuitry without connecting the circuitry to arduino. Power up and upload the skecth. Power down and introduce the external circuitry. Power up and we have a working project without breaking our arduino.

Just Making sure i got things right :) and thanks for the good answers. Getting my arduino today, so im pretty psyched!

If I think of it, I tend to load something harmless first and then tear down the old project, Sometimes I'm not planning on changing projects, and then do it the way you describe.

Another way to do it is add code not to do anything until a switch is set (say on data line 2), and always keep the switch on the same pin. If you are switching shields and stuff this may not be possible due to different pin assignments.

I suspect as a matter of general principals, if possible, you may not want to put anything on pin 13 but a LED, so blink can be used as a program in between tasks.

MichaelMeissner: I suspect as a matter of general principals, if possible, you may not want to put anything on pin 13 but a LED, so blink can be used as a program in between tasks.

Yep, the LED pin is a bit problematic to use at all because some bootloaders will blink the LED to indicate status - like a reset.

If you use the LED pin - even with your final sketch code in place - it can be driven in ways you never intended when the AVR is reset.

--- bill

just disconnect the power from the Arduino to the breadboard

Hey i got a question again. This time its about using a servo and not exceeding the current limit. I just came across to an example where the servos signal wire was connected to the arduinos pin 9, Red wire to arduinos +5 Volts and the black one to ground. I thought servos use pretty much current. So doesnt this kind of circuit exceed the 20mA limit of arduino. Heres a link to the circuit schematic and the example mentioned. http://www.oomlout.com/oom.php/products/ardx/circ-04

servos run from the 5 volt line of the Arduino or 5-6 volt battery (thats is why there is 3 wires) the red wire goes to +5 the black wire to ground and the (usually white) wire goes to pin 9 or any other pin. it uses the pin’s <20 mA signal to tell the motor to turn using the 5 volts. Most servos draws around 100-300 mA
So just using USB power I would not use for than 1-2.

arduinopi:
servos run from the 5 volt line of the Arduino or 5-6 volt battery (thats is why there is 3 wires) the red wire goes to +5 the black wire to ground and the (usually white) wire goes to pin 9 or any other pin. it uses the pin’s <20 mA signal to tell the motor to turn using the 5 volts. Most servos draws around 100-300 mA
So just using USB power I would not use for than 1-2.

But if it uses the aruinos 5 volts doest that exceed the current limit of 200 mA or something. Isnt external always needed.

Not always. depending on how large the servo is you can use it with USB power. I have had no problem using 2 small servos with USB. As for the 200 mA cap I have never heard of that I have drawn 450 mA from the +5 of the Ardunio. If you are using a lot of servos > 2 I would recommend getting a larger power supply.

arduinopi: Not always. depending on how large the servo is you can use it with USB power. I have had no problem using 2 small servos with USB. As for the 200 mA cap I have never heard of that I have drawn 450 mA from the +5 of the Ardunio. If you are using a lot of servos > 2 I would recommend getting a larger power supply.

But to be sure its better to use external battery etc?

yes you can tell if your drawing to much current by looking at the Ardunio power led if it dims you are using a lot of current. To be safe I would use a battery pack.

houpsi: But to be sure its better to use external battery etc?

If you are using servos or motors, you want to plan to have separate power for the servo/motor and the Arduino, since servos/motors take a lot of power. With one or two you might be to power it directly from the Arduino. I got a servo in the combo pack of the Arduino I bought, and I can power it with the Arduino, but if I add on my DFRobot LCD shield there isn't enough power for both the LCD and servo when I'm powering my Arduino from USB.

If you are using external power for the motors, you want to connect the ground wires together between the Arduino and external power.

If you think you are going to go between projects, one of the things I've been experiencing is having to tear down and rebuild the breadboard for each different project. I have moved to a larger breadboard, so I can keep many of the components in the breadboard and just wire in what I'm using.

But as I think about going between projects, I've been thinking about getting several protoshields and mini-breadboards (such as http://arduino-direct.com/sunshop/index.php?l=product_detail&p=93) and then I don't have to rewire things to change projects, all I have to do is take off one shield and put in another. Obviously you will need duplicates LEDs, buttons, pots, etc.

It probably depends on whether you think you would do multiple projects or not. I could also imagine having one breadboard for a project at a given state, and the other for the next generation.