Store new values

Hey guys,
i am using 2 arduino Mega .
arduino Mega1 is connected with TFT touch and arduino 2 is connected with Relays.
Arduino 1 and 2 are connected to each others (Serial communication).
i am using arduino 1 (TFT) to change some values on arduino 2 .
everything works but the problem is when i reset the second arduino the new values are not stored.
so the question is how can i store the new values.
this is the Code:
Arduino 1

#include <UTFT.h> 
#include <UTouch.h>
void setup() {
// Initial setup
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
    drawHomeScreen();  // Draws the Home Screen
    
  currentPage = '0'; // Indicates that we are at Home Screen
  selectedUnit = '0'; // Indicates the selected unit for the first example, cms or inches
 
  pinMode(Relai, OUTPUT);
  Serial.begin(9600);
Serial1.begin(9600); 
Serial2.begin(9600); }
void loop() { 

// Home Screen
  if (currentPage == '0') {
if ((x>=140 && x<=160 && y >=325 && y<=350)   ){
 drawFrame(140, 325, 160, 350);  
 Serial2.println('+');
   }}}
void drawFrame(int x1, int y1, int x2, int y2) {
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (x1, y1, x2, y2);
}
Arduino 2

int waterminute0 ;
void setup() {

Serial.begin(9600);
Serial1.begin(9600);
while(!Serial);    // time to get serial running

}
void loop() {
if (Serial1.available() ) {
Char=Serial1.read();
Serial1.print(Char);
if (Char=='+') {
waterminute0=waterminute0+1;
}
}

https://www.arduino.cc/en/Reference/EEPROM

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