"Frying" an Arduino by running a sketch

Good afternoon...

Can an Arduino (for instance a NANO or any other similar device) get "fried" just by running a sketch?
(Such as a sketch with conflicting instructions.)

I cannot think of such a sketch, likely because I am still green behind my ears (I have successfully done 3 projects so far), but it would be interesting (especially for beginners) to know what to avoid when coding the controller, unless one wants to transform the Arduino into a toaster.

Cheers,

Eric

If nothing external is connected to the board other than the USB lead then you cannot "fry" the board with a sketch, Instructions are executed one at a time so even if the code did something like setting a pin to OUTPUT and the next instruction set the same pin to INPUT then no harm would ensue

However, once you connect anything to the board then all bets are off

2 Likes

I must look up the origin of that expression. I've never understood it.

We could just as well say "once you connect anything to the board then place your bets"

It means that the circumstances under which bets were placed have changed and hence previously placed bets are now invalid, ie they are off

Most likely trying to drive a relay, light, motor or some other peripheral directly from a pin that won’t support the external device.

Second would be applying an invalid voltage to any pin.

connecting a 5V source to a 3V3 input is rarely a good idea.

Datasheets may seem like a lot of unnecessary blah-blah, but there are simple tables that specify limits of i/o pins and the like.
Just like well planned schematic diagrams they help a lot once you understand them.

If damaging your board is what you are looking for, make a sketch to continuously rewrite eeprom. You still need plenty of time...

So...
All in all, if you really want to toast your Arduino, you must deliberately get the physical connections wrong or overload the whole lot.
There is no real possibility to do it via a "code".
Except maybe writing stuff to the EPROM till it's dead.

There is at least one possability where a connected hardware can damage a microcontroller through a wrong sketch:

If a switch or a button is connected on one end to an IO-pin and the other end is connected to ground.
In combination with a sketch that does two additional things:

  • configuring this IO-pin as OUTPUT
  • setting this IO-pin HIGH

if the switch is closed then this would be a shortcut between 5V on the IO-pin beeing "HIGH" and ground. Then a too high current would flow from IO-pin to ground damaging minimum this IO-pin maybe more of the microcontroller.
Same if the button would be pressed to close the contact.

The same thing applies if the switch/button would be wired between IO-pin to +Vcc and then the sketch would

  • configuring this IO-pin as OUTPUT
  • setting this IO-pin LOW

This would be a shortcut between +Vcc and IO-pin making a too high current flow damaging the IO-pin.

This can be avoided by inserting a current-limiting resistor between IO-pin and whatever you connect to this IO-in

instead of directly IO-pin---------your-hardware
.
.
IO-Pin-----resistor-----your-hardware

In most cases the function of "your hardware" will be the same.
In most cases the influence of the current limiting resistor will be too small to ahve an result-changing effect.

In some cases this current-limiting resistor will have a result-changing effect.
This would be the case if the "your hardware" has an inpedance in the same range as the resistor.
For things like I2C-sensors, buttons, switches it will work.
You can ask in the forum for a specific hardware.

For some microcontrollers that have a software configurable clock, too high overclocking using very special configuration-functions might result in overheating the microcontroller.

The microcontroller-word is not super-standardised like USB-devices or bluetooth.
You have to take care of more details like

"does the plug fit into the socket?"

You should have a basic knowledge about voltage, current, resistance and Ohms law.
The arduino-forum has a sub-forum general electronics. So if you have a question which is mainly about electronics you could post this question there.

1 Like

Interesting answer...
Indeed, the buttons in combination with high/ground will kill the board (or seriously damage it...)

Thanks for your input.
I hope that it will make newbies aware of what not to do when connecting their board...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.