How to Clear Arduino Memory?
How to Clear Arduino Memory?
5 (100%) 5 vote[s]

An Arduino has three forms of memory: RAM, Flash, and EEPROM.

When the Arduino is reset, the contents of the RAM are deleted. The variables and registers, as well as the instruction pointer, are all used.

Flash memory is used to store the code. Whenever the Arduino is reset or switched off, this information is not lost.

You should store data in EEPROM if you don’t want it to be deleted. You can’t simply designate a variable to be in EEPROM; you have to do so directly. It’s good for storing configuration data that doesn’t alter often but that you don’t want to change every time the Arduino is turned on or reset.

The created data inside a sketch only takes as long as the Arduino is turned on when you identify and use a variable. The data contained on the Arduino is lost whether it is reset or turned off.

What is EEPROM?

Each Arduino board has separate memory storage in the microcontroller. It is called Electrically Erasable Programmable Read-Only Memory (a.k.a. EEPROM).

Byte variables may be stored in this tiny storage space. When you reset or turn off the Arduino, the variables contained in the EEPROM remain there. Simply stated, an EEPROM is a form of permanent storage that works similarly to a hard drive in a device.

Electronically, the EEPROM may be interpreted, deleted, and rewritten. Using the EEPROM library in Arduino, you can quickly read and write from the EEPROM.

How many bytes can you store?

Only 8-bit numbers, such as integer values between 0 and 255, can be stored in each EEPROM location, which implies you only can store 8-bit numbers.

The number of bytes you may store in EEPROM is determined by the Arduino microcontroller:

The microcontroller of Arduino EEPROM size
ATmega2560 (Arduino Mega) 4096 bytes
ATmega328 (it can be found in Arduino Uno, Nano, Mini) 1024 bytes
ATmega168 (Arduino Nano) 512 bytes


You can get an additional (external) EEPROM if you require storing more data.

The EEPROM’s lifespan is restricted. The EEPROM in Arduino is set to manage 100 000 write/erase cycles per place. Reads, on the other hand, are limitless. This ensures that you will be able to read from the EEPROM as many times as you like without jeopardizing its longevity.

The EEPROM is helpful in Arduino projects that require data to be retained even though the Arduino is reset or power is turned off.

It’s especially useful for recalling a variable’s last state or the number of occasions a device was turned on.

For instance, you may use this feature in such scenario:

  • You’re using the Arduino to operate a lamp, and the lamp is turned on; 
  • The Arduino accidentally loses power; 
  • When the power is restored, the lamp remains off – it doesn’t remember its previous setting.
  • This is what you don’t want to occur. You may need the Arduino to remember what happened before it lost power and go back to its previous condition;

To solve this dilemma, save the lamp’s state in the EEPROM and provide a condition in your sketch that checks if the lamp’s current state matches the state saved in the EEPROM storage.

How to clear Arduino memory with coding: 

  • You need to find the basic empty setup program (sometimes it is called a loop);
  • Then you should compile it;
  • Reset the Arduino board. Push the hardware button (usually located on the chip);
  • Then you need to press the key combination of Ctrl + U. It will upload the code;
  • If nothing happens, repeat the previous step once again;

Before the boot loader launches the program, there is an expected delay; just wait for it. It may cope with the potential bugs in Arduino’s code when executing a soft reset every 500 ms.

How to reset/clear Arduino Leonardo board memory?

Here is the simple algorithm of actions: 

  • The USB cable must be unplugged;
  • Connect the RX pin to the ground;
  • The USB cable must be plugged;
  • Upload a new program;
  • Remove the cable;
  • Remove the RX grounding;

Make sure the Arduino is connected directly to the PC device rather than via a hub.

Another simple solution that may work:

  • Unplug the USB cable;
  • Select the Device Manager;
  • Select Ports (COM & LPT)
  • Press the right click on your Arduino board (COMx);
  • Then choose “Properties – Port Settings – Put flow control to Hardware”;
  • Create an empty sketch (the example is below);
  • Again connect the USB cable;
  • Upload by pressing Ctrl + U;

Here is an example of an empty sketch that you may use:

// Empty sketch

void setup()



// The loop routine goes over and over forever:

void loop()




When the Arduino is powered on, it will run the last program that was installed on it. If you don’t want it to go, don’t turn it on.

The Arduino normally runs the Blink program right out of the package. If you want to “reset” it, you may simply load that and call it a day.

Alternatively, you might use a loop program with a sleep button.

However, if you’ve been tinkering with the USB bootloader through the pins, you’ll have to reboot the bootloader. However, if you’ve been uploading programs through USB or directly utilizing a compiler, uploading Blink or another dummy program to reset it should be no problem.

How to reset or clear Arduino Uno board memory?

If you’ve ever worked with an Arduino board, you’ve probably come across the RESET pin and wondered what its purpose was. So, this pin will come in handy.

Furthermore, you might have found that when uploading the code to your Arduino board, it resets. Another method to reset Arduino is to open the Serial Terminal in the Arduino program when attaching your Arduino board to your device. The Arduino is immediately reset when you launch the Serial Terminal. The push button is the third method of resetting Arduino. Arduino will reset as you click and release the push button.

To “reset” the Arduino, follow these steps. Switch it off, hold down the Reset, and then turn it back on while still holding down the button. The original sketch can no longer work as a result of this. After that, you should create a new sketch.

Related Video: How to Clear EEPROM in Arduino

How to clear any sketch from any Arduino board?

Consider loading the sketch into the flash memory as if you were flashing an OS file onto your Raspberry Pi SD card. This sketch will load any time you plug in the power. However, with a microcontroller, it loads almost instantly.

Since the Arduino chip is programmed to be flashed with a program, it can remain on the chip until it is flashed again, regardless though it has been turned off and on.

If you want to set up your Arduino board for a new circuit, consider uploading the Blink program first because it’s the simplest and fastest way to “reset” to a common starting point.

Hi! My name is Tom and I’m an author of the blog. My hobby is electronic circuits and soldering irons.

Related Posts

Resistor Color Codes

Resistor Color Codes

A resistor is a two-terminal passive electrical part that acts as a circuit element by implementing electrical resistance. Resistors are used in electrical circuits for a variety of purposes, including reducing current movement, adjusting signal speeds, dividing voltages, biasing active components, and terminating transmission lines. A resistor is a component that regulates the flow of current…

How to Tell if Arduino is Fried?

How to Tell if Arduino is Fried?

“Frying” does not imply putting the Arduino in a frying pan and turning it on. It describes a situation when the board has been electrically damaged and is no longer usable. If you notice a burning odor coming from your Arduino, it's time to replace it. Through adding incorrect voltages or creating inappropriate links, people often…

How to Tin a Soldering Iron: Guidelines and Tips

How to Tin a Soldering Iron: Guidelines and Tips

Most soldering irons have a copper tip. As a simple and useful tool, it is applied not only by a specialist but also by handymen who occasionally need to work with electronics. For example, if you need to join two wires or repair a household appliance. However, not all novice users remember the most important…

How to Solder Stainless Steel

How to solder stainless steel

The process of soldering stainless steel seems challenging, but don’t expect big difficulties. Alloys containing less than a quarter of chromium and nickel are easy to fuse. Moreover, these alloys can create strong bonds with other metal elements, excluding aluminum and magnesium. Understanding the process and preparation Remember that some nickel-plated alloys can form carbides…

Leave A Comment

Your email address will not be published. Required fields are marked *