Storing a 5 digit number in the EEPROM

I am trying to store about 10 five digit number in the EEPROM of the arduino using the standard EEPROM library functions. EEPROM.write() function only allows to store numbers from 0 - 255!! How can i store codes like 12322 or 14453 in the EEPROM?

An unsigned integer can hold values up to 65535.

void writeWord(unsigned address, unsigned value)
   {
   EEPROM.write(address, highByte(value));
   EEPROM.write(address+1, lowByte(value));
   }

unsigned readWord(unsigned address)
    {
    return word(EEPROM.read(address), EEPROM.rear(address+1));
    }

the number is actually being sent from my pc to the arduino through the serial port!! how do i separate that number into a higher bit and a lower bit

also could explain to me how this code is working?

unsigned readWord(unsigned address)
{
return word(EEPROM.read(address), EEPROM.rear(address+1));
}

also highByte() and lowByte() inbuilt functions in the arduino?

ujjwol77: also could explain to me how this code is working?

http://arduino.cc/en/Reference/WordCast

http://arduino.cc/en/Reference/LowByte http://arduino.cc/en/Reference/HighByte

the number is actually being sent from my pc to the arduino through the serial port!! how do i separate that number into a higher bit and a lower bit

Exactly the same way you would any other int.

If the PC is sending the number as a string, you need to collect the whole packet, and then convert that string to an int.

thanks for the help!! one last thing i would like ask... How many 5 digits number can i store in the atmega328PU's EEPROM using the code given above

yes the packet is being sent as a string from the PC using Visual C# and i have converted into the int! Now can i store this int in the EEPROM based upon the code suggested above

ujjwol77:
thanks for the help!! one last thing i would like ask… How many 5 digits number can i store in the atmega328PU’s EEPROM using the code given above

http://arduino.cc/en/Reference/EEPROM
"The microcontrollers on the various Arduino boards have different amounts of EEPROM: 1024 bytes on the ATmega328, "

That can hold 512 words (16-bit) values.