Pages: [1] 2   Go Down
Author Topic: A newbie who doesnt want to break his new arduino uno  (Read 1374 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Tucson, AZ
Offline Offline
Sr. Member
****
Karma: 8
Posts: 311
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
void setup() {
  // put your setup code here, to run once:

}

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


Lefty
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 517
Posts: 26282
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: July 11, 2012, 07:57:25 pm by bperrybap » Logged

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

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 smiley and thanks for the good answers. Getting my arduino today, so im pretty psyched!

Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 53
Posts: 1829
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley 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.
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 403
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just disconnect the power from the Arduino to the breadboard
Logged

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

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
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 403
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 403
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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?
Logged

Pages: [1] 2   Go Up
Jump to: