How to change a variable in arduino code that is effective even after restart

Hi, please find my code attached. It is for an irrigation system I'm using for watering plants in my balcony. It has 8 alarms(1-8) for activating the pump, 1 alarm for screen timeout, 1 alarm for alarm timeout.

The important part of the code is below, this part is placed before void setup() in my code.

So during startup, Arduino uses values in below arrays to set several alarms.

My problem is, when I change a value from screen, it works well until a restart. When I restart arduino for some reason, I have to enter these values again. This is creating many troubles especially when I'm travelling for a long time.

Is there a way to set these values on the fly, but it is also effective even after restart? Maybe writing the array into Progmem and change it there? Or using an sd card to boot and re-write into sd when the value needs to be changed?

byte alarmID[11] = {0, 1,  2,  3,  4,  5,  6,  7,  8,  9, 10};         //Create alarmID array with default values.
      byte H[11] = {5, 2,  6, 11, 12, 14, 15, 17, 21,  0,  0};         //Create an array named H for hours, assign values(5, 7, 11, 13, 15, 17, 21, 23, 0)
      byte M[11] = {0, 0, 30,  0, 30,  0, 30,  0, 30,  0,  1};         //Create an array named M for minutes, assign values
      byte S[11] = {0, 0,  0,  0,  0,  0,  0,  0,  0, 30,  0};         //Create an array named S for seconds, assign values

Thanks a lot in advance for all your support.

Irrigation_V2.ino (20.6 KB)

EEPROM ?

Any more info about how can I do that?

In the part of the code where you change the alarm variables, after you make the changes save them to EEPROM. Then, in setup(), retrieve the values from EEPROM and write those value to the alarm variables when the processor resets.

Be aware that EEPROM is guaranteed for 100,000 writes. Probably not in issue for your use, but be aware. The number of reads is unlimited.