how long will a sketch run for?

So as the title suggests.

how long will a sketch run for once its been set up to run after been powered up? will it need to have the memory on the board refreshed in anyway?

for example using up memory from printing characters in serial?

is there any way of getting around it etc?

id like my program to just keep running for ever really untill something is disconnected or told to do something else


A century or so, if well-written, maybe longer.

I have an Atmega328 controlling my fridge 24/7 for the past 18 months. I expect it will work for years.

The only part that can wear out is the EEPROM memory which can only be written to about 100,000 times. You may not need to use that at all, and it is probably easy to ensure that you stay within that limit for a very long time. You could write to a byte once an hour for about 11 years.

Of course you must ensure that the device is not electrically overloaded or subject to voltage spikes or the like.


ok thats good to know then.

so its bassically like RAM then and it keeps re-writing the data to that memory and resetting it?

I have two motors running off my arduino UNO.

both 12v, gaining their power from the Vin pin and controlled by two IRFZ44N transistors. According to the data sheet and what i have read, the Arduino is able to handle up to 1amp from this pin?

1 motor draws initially 200ma then its a little lower once up and running. Both protected by Diodes even though there should be no chance of the motor providing power due to them needing a high torque to turn in the first place. Also i have a capacitor over each as i was told this was to drowned out noise?

I hope this is right anyway.

Is it normal for the motors to try turn on when uploading new code to the arduino? is this down to the pins becoming live for a split second while its uploading? It works fine every other time when i plug it in.

Don't power motors from the Arduino.

If you have a power supply with sufficient amps (i.e. a bit more than you could ever possibly need) you can power the motors and the Arduino directly from it. Otherwise have two separate power supplies with a common GND connection.


i thought powering the motor from the Vin pin would be fine as its directly from the supply anyway?

its just another wire but connected to the board so it doesnt actually go through the ardiuno chip.