I have noticed that some atmel chips can do "self programming" and I'm doing a hobbyist project where I need to change the "setting" of my arduino without code-reuploading through Arduino IDE.

Is it possible to do that ? If it's possible. Please give me some basic though about how to do it.

Thanks in advance !

6 Answers 6


There are two areas of non-volatile storage in an Arduino: Flash and EEPROM.

Flash is where your program and constant values are stored. Variables with default values also have their default values stored in Flash.

EEPROM is a much smaller area with no real fixed purpose - you can store whatever values you want in there.

Flash can only be written to by code that is in the bootloader area of flash. This is important. A program cannot modify itself. Only the bootloader can modify a program - and then only in chunks ("pages"). It has to erase a whole page before it can write data to it.

The reason why you can't modify Flash from your main program is simple: Flash is the only place code can be executed from. If you erase the page of flash that contains the code that is programming the Flash then everything dies. Horribly. So it's stopped in its tracks by not allowing it to happen in the first place.

EEPROM, conversely, can be written to by anything - the bootloader or the main program. And on top of that individual values can be modified at will - no need to erase pages.1

So to answer the question behind your question ("How can I store and modify settings?"): it's quite simple - store them in EEPROM.

The IDE has examples of how to use the bundled EEPROM library, and there are more details in the Arduino reference manual.

1: Some systems don't have EEPROM, so they emulate it using Flash. These systems still have to erase the Flash in pages, but they try to do it transparently. Some (such as the ESP8266) use a commit() method to update a batch of values. Others, such as chipKIT boards, use wear levelling and separately indexed writing to reduce the need to erase pages.


You have multiple options to change settings without code-reuploading. By settings I mean values, not code.

First, you can add a physical UI to your project. It can be a push button and a LED, a key pad with a LCD display or a touch sensitive screen.

Second, your sketch can use Serial as way to receive comands and display information. You will need a tablet, smartphone or PC.

Third, you can also use Bluetooth instead of Serial.

Fourth, you can add WiFi to your project. With WiFi any solution is posible (web page, Android App ...).

You can also mix technologies: have a minimal physical UI for emergencies and a full interface via WiFi.

With NodeMCU you also have a file system where you can store you app data. It may be simpler to use than EEPROM.


Yes, you can self-program these. There are several different bootloaders you can use to do this - here's one: https://bitbucket.org/talk2/talk2boot


You can write to the non-volatile memory of the microcontroller and then read it again during setup.

Another (perhaps simpler) option is to have an external eeprom chip in a socket to hold the settings so you can program that separately from the module. That way you don't need to have a menu in your project.

  • OP is asking how to change values.
    – user31481
    Oct 18, 2017 at 10:10

Self programming is used by Arduino bootloader. If you want something special, you have to change bootloader, because you can't call SPM instruction outside of BOOT sector (the only exception are AVRs with a small program memory).

I'd recommend to use internal EEPROM storage instead.


You can do something simple - say have 2 pins to select 1 of 4 sets of values for the code to use. Read the pins in setup(), and change values to use in loop() accordingly.

void setup(){
change = PIND & 0b1100000; // say D7/D6 used on a Uno.
switch (change){
  case 0b00000000:
  // set values for D7/D6 = 00
  case 0b01000000:
  // set values 01
  case 0b10000000:
  // set values 10
  case 0b11000000:
  // set values 11

Or wait in setup() for the choice to come in a Serial message. Maybe store the sets of values in EEPROM for selection via whatever source, and then let the code change the values if needed. Or think of other ways to select the values without having to change the existing bootloader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.