What, if I use the "wrong" hardware?

Hi *,

did I introduced myself? My name is Andreas, I live in Germany and earn my life as application administrator. Some months ago I found my passion for robots and then mikrocontrollers. But the environment with ISP and so is (still) a little bit complicated for me ;). So I searched for an alternative and stumbled over Arduino. After gambling around with LEDs, RGB LEDs, sensors and servo I stumbled over following:
I had a sketch for a sort of ultra sound radar (SRF05 and servo). Then I demounted this and built up two RGB LEDs to test them; after writing the new sketch I connected the Arduino to upload it, but the other sketch started running.

So my question is: can I damage the arduino or the connected hardware by using a "wrong" sketch for the hardware?

best regards
Andreas

Worst case scenario:

No, but seriously, you can't damage the chip by programming it wrong. Not with the Arduino.

The worst you can do is set the fuses wrong (if the wrong chip is selected) and the sketch just won't run. All you're doing is programming flash. You can re-program it thousands of times. You could program it with just random junk and, while it won't do anything useful, it won't damage it.

You're far more likely to damage it by connecting things up wrong, or using wrong voltages, etc.

you can't damage the chip by programming it wrong.

Well you can if you have an output feeding into an arduino input and you program that pin to be an output. If then the external output and the arduino one are different levels you can damage the arduino pin.

Hi majenko,

thanks for the quick answer - this takes some anxiety from me. I thought more this:

:smiley: :grin: :smiley:

I'm curious when I will connect a LED to 9V for the first time ]:smiley:

best regards
Andreas

I'm curious when I will connect a LED to 9V for the first time

So long as the other end of the LED is not connected to the arduino then it is fine.

Hi Grumpy_Mike,

thanks for the answers!

Grumpy_Mike:

you can't damage the chip by programming it wrong.

Well you can if you have an output feeding into an arduino input and you program that pin to be an output. If then the external output and the arduino one are different levels you can damage the arduino pin.

With "other level" do you mean other voltage? So if I have only 5V everywhere can that be OK?

best regards
Andreas

Without connecting anything to it, it would be hard to hurt it. However once you start connecting things you have to take a certain amount of care. Read this:

Basically, a "wrong" sketch might try to output to a pin that was shorted to ground, for example. Or drive too many LEDs for the current rating of the chip.

I connected the Arduino to upload it, but the other sketch started running

What other sketch? A sketch you upload stays there until you upload a different one. Even after you power it off.

With "other level" do you mean other voltage?

No I mean if a pin is outputting a logic zero and it is connected to +5V, like in the way buttons are wired up in some of the tutorials, then the pin will be damaged.

If you wire it up the other way, with the button connecting the pin to ground and you output +5V from the pin you might think that would also do the same damage, but experience says that a pin is more likely to survive that way round. It's still bad though.

So basically getting a pin to be an output when it should be an input is a bad thing. That is why I always down load the basic sketch before connecting and hardware to the arduino as you never know what was there the last time.

First: Thanks to all for the answers.

I had a sketch, which handled a servo and an ultra sound device (let's call it "ultra sound radar" :)). After disconnecting these devices and connecting RGB LEDs for the next test, I connected the Arduino to the computer to upload the RGB sketch, but during the time between USB connection and uploading the new sketch the "radar sketch" was running for a short time (an a LED started glowing). This was the reason for my question. It seems that I have to be careful.

Grumpy_Mike:
That is why I always down load the basic sketch before connecting and hardware to the arduino as you never know what was there the last time.

OK - will do my very best to follow this advice.

best regards
Andreas

Even the basic Blink sketch might causes some hardware, attached to pin 13, to malfunction. If you were worried you could either:

  • Disconnect all hardware (eg. shields) before powering on the device. Of course, you don't do this if you know that the sketch currently on the chip is supported by the currently-connected hardware.
  • Upload a "do nothing" sketch before disconnecting whatever is currently connected.

Example "do nothing" sketch:

void setup () {}
void loop () {}

Thanks to all and a special thank to Nick for the link!

best regards
Andreas

@Nick: hardware that will be damaged if Pin 13 starts to go high is better not connected to the Arduino anyway. Otherwise you have to get rid of the bootloader.