Go Down

### Topic: How to divide a number in two bytes (Read 412 times)previous topic - next topic

#### ciao4735

##### May 16, 2019, 10:20 am
We are trying to save a number > 255 in a EEPROM cell. Please we need an example code.

#### srnet

#1
##### May 16, 2019, 10:46 am
Examples here;

EEPROM Library

That reference page turns up when you do a Google search on 'Arduino EEPROM reference'
http://www.50dollarsat.info/
http://www.loratracker.uk/

#### GolamMostafa

#2
##### May 31, 2019, 05:00 amLast Edit: May 31, 2019, 05:01 am by GolamMostafa
We are trying to save a number > 255 in a EEPROM cell. Please we need an example code.
Code: [Select]
`int x = 321; //0x0141EEPROM.write(0x0010, highByte(x));      //0x01 is written at location 0x0010 of internal EEPROMEEPROM.write(0x0011, lowByte(x));      //0x41 is written at location 0x0011 of internal EEPROM`

#### sterretje

#3
##### Jun 01, 2019, 07:24 pm
Use EEPROM.put() and EEPROM.get(); it will write and read any variable type as needed (with exception if String (capital S)).
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

#### GolamMostafa

#4
##### Jun 02, 2019, 12:55 am
Use EEPROM.put() and EEPROM.get(); it will write and read any variable type as needed (with exception if String (capital S)).
The OP is asking for the division of a number into two bytes before the number is stored into EEPOM. The EEPROM.put() command, of course, divides the number into two bytes before writing it into EEPROM; but, the process happens beyond the knowledge of the user.

#### sterretje

#5
##### Jun 02, 2019, 06:00 am
The OP is asking for the division of a number into two bytes before the number is stored into EEPOM. The EEPROM.put() command, of course, divides the number into two bytes before writing it into EEPROM; but, the process happens beyond the knowledge of the user.
Based on the title, you are right. Based on the text (store a number greater than 255), my solution is also a possibility

Although OP asks "in a cell" which is not posible; it will be two or more cells.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up