How to write more than number 255 in EEPROM?

I need to record the weights of my load cell in eeprom, some weights arrive at 4 digit boxes, eg 2560 "kg", I need to record these 4 numbers in space, but I can't with EEPROM.write.

Also, how many of these "weights" could I record on an Atmega 2560?

post your code

There are many ways to store values in the EEPROM and on the standard Arduino, 512 bytes to contain those values. Each byte is individually addressable.

I can't with EEPROM.write

Where did you get that idea?

Post your code, using code tags as described in How to use this forum.

The general answer is: use EEPROM.put(), which can write any type to EEPROM:

The important thing to remember is that different types take different amounts of EEPROM. So if you are writing a byte type to EEPROM, it only needs a single byte, because the byte type is one byte. If you are writing a long to EEPROM, then it take 4 bytes of EEPROM. This means if you write a long to EEPROM address 2, then you are also using EEPROM addresses 3, 4, and 5 to store that data. So the next available EEPROM address would be 6. If you were to think the next available address was 3 then when you wrote to it you would corrupt the long data you stored starting at address 2. The way to handle this programmatically is using the sizeof() function, which returns the number of bytes of a variable.

As for a specific answer, you would need to do as codeman22 requested.

You cannot store 2560 in one digit ether. You just used 4 without thinking about it. Its the same with bytes. You will have to learn how to separate your values into bytes or use other function available in the EEPROM library.

Edit: Looks like pert beat me to it while I was typing.

LukeDaniel19:
I need to record the weights of my load cell in eeprom, some weights arrive at 4 digit boxes, eg 2560 "kg", I need to record these 4 numbers in space, but I can't with EEPROM.write.

Also, how many of these "weights" could I record on an Atmega 2560?

Use two bytes per weight. 2560kg expressed in hex is AA00h. So write the high-byte (AA) to location 'N' and the low byte (00) to location N+1.

//Pseudocode
EEPROM.write( N, (weight >> 8);
EEPROM.write( N+1, (weight & 0xff) );

Read them back in the same order and re-assemble into an int:

//Pseudocode
int weight = EEPROM.read(N)<<8 + EEPROM.read(N+1);

The 2560 has 4K bytes of EEPROM so you could, in theory, store 2048 weights.

Curious.
Weights tend to be transient, passing values... why store them in EEPROM unless they are calibration values etc ?

Blackfin:
Use two bytes per weight. 2560kg expressed in hex is AA00h.

sp. "0A00h", or better still "0xA00".

codeman22:
post your code

EEPROM.write(a2+1,p1/1000);
EEPROM.write(a
2,(p1%1000)/10);
M[a]= EEPROM.read(a*2+1)100+EEPROM.read(a2);

(I can't use tag code now)

So, in the up example, i divide my weights in two and i write, but, my variable "a" is equal to 2, for example, i guess that code is very wrong.

TheMemberFormerlyKnownAsAWOL:
sp. "0A00h", or better still "0xA00".

Oops. Thanks for that.