user30152: I am working on an Arduino Mega 2560. I want to read and write the internal EEPROM.
Can I use EEPROM.get()/EEPROM.put()?
I want to store 3 things in EEPROM:

Boolean status.
String password: length 5 digits.
String Mobile number: length 10 digits.


user13432: 
How do I write and read internal EEPROM? Can I use EEPROM.get()/EEPROM.put()?

Yes, the Arduino Reference for EEPROM contains an example of what you are asking for. Below is a simple rewrite of the example for EEPROMGet for your info.
struct MyObject{
  bool status;
  char password[6];
  char mobileNumber[11];
};

void setup() 
{

  int eeAddress = 0; //EEPROM address to start reading from

  Serial.begin( 9600 );
  while (!Serial) ;

  MyObject customVar; //Variable to store custom object read from EEPROM.
  EEPROM.get(eeAddress, customVar);

  Serial.println(F("Read custom object from EEPROM: "));
  Serial.println(customVar.status);
  Serial.println(customVar.password);
  Serial.println(customVar.mobileNumber);
}

For more details and examples see https://www.arduino.cc/en/Reference/EEPROM.
Cheers!

user30198: Avoid the 'String' object, use a character array of fixed length. You might want to add one extra byte for the zero-terminator. Put everything in a 'struct' and then you can use the EEPROM.get() and EEPROM.put() to read and write the complete struct. I prefer a struct to keep the data from EEPROM together. That makes it easier to add a checksum and a version number for the data. When something is wrong with the data from EEPROM then default values could be used.
Instead of a struct, you can also read and write the seperate items. The EEPROM.get() and EEPROM.put() should be able to use a character array of fixed length.

30152: <p>I am working on an Arduino Mega 2560. I want to read and write the internal EEPROM.</p>

<p>Can I use <code>EEPROM.get()/EEPROM.put()</code>?</p>

<p>I want to store 3 things in EEPROM:</p>

<ol>
<li><p>Boolean status.</p></li>
<li><p>String password: length 5 digits.</p></li>
<li><p>String Mobile number: length 10 digits.</p></li>
</ol>
 13432: <blockquote>
  <p>How do I write and read internal EEPROM? Can I use EEPROM.get()/EEPROM.put()?</p>
</blockquote>

<p>Yes, the Arduino Reference for EEPROM contains an example of what you are asking for. Below is a simple rewrite of the example for <a href="https://www.arduino.cc/en/Reference/EEPROMGet" rel="nofollow noreferrer">EEPROMGet</a> for your info.</p>

<pre><code>struct MyObject{
  bool status;
  char password[6];
  char mobileNumber[11];
};

void setup() 
{

  int eeAddress = 0; //EEPROM address to start reading from

  Serial.begin( 9600 );
  while (!Serial) ;

  MyObject customVar; //Variable to store custom object read from EEPROM.
  EEPROM.get(eeAddress, customVar);

  Serial.println(F("Read custom object from EEPROM: "));
  Serial.println(customVar.status);
  Serial.println(customVar.password);
  Serial.println(customVar.mobileNumber);
}
</code></pre>

<p>For more details and examples see <a href="https://www.arduino.cc/en/Reference/EEPROM" rel="nofollow noreferrer">https://www.arduino.cc/en/Reference/EEPROM</a>.</p>

<p>Cheers!</p>
 30198: <p>Avoid the 'String' object, use a character array of fixed length. You might want to add one extra byte for the zero-terminator. Put everything in a 'struct' and then you can use the EEPROM.get() and EEPROM.put() to read and write the complete struct. I prefer a struct to keep the data from EEPROM together. That makes it easier to add a checksum and a version number for the data. When something is wrong with the data from EEPROM then default values could be used.</p>

<p>Instead of a struct, you can also read and write the seperate items. The EEPROM.get() and EEPROM.put() should be able to use a character array of fixed length.</p>
