I have a project that uses a state machine with a master counter. The counter will have a maximum value of 750 or so. The state will be no larger than 50. As the counter updates every second it needs to be stored along with the state. The life span of the EEPROM rules him out so I decided to use the leftover space on the RTC memory map. On power up I will read the contents of the ram to get state and counter values (If there was a power outage the numbers will not be state = 0 and counter = 0) and plug those values into the program during setup so that the state machine can resume where it left off.

.....So the question is how best to cut up that 750 number to store it in a couple of bytes on the RTC and then to reassemble the number after reading from the RAM.

Did you bother looking at the reference page?http://arduino.cc/en/Reference/WordCast

I did and found it rather terse. I have established two way communications with the RTC that is working with only a few bugs.The code is ugly and I don't understand everything going on yet but the real issue is the smashing and reconstruction of the data.

void loop() { if (Serial.available()) { // Look for char in serial que and process if found command = Serial.read();

if (command == 81 || command == 113) { //If command = "Qq" RTC1307 Memory Functions delay(100); if (Serial.available()) { command = Serial.read(); if (command == 49) { //If command = "1" RTC1307 Initialize Memory - All Data will be set to // 255 (0xff). Therefore 255 or 0 will be an invalid value. Wire.beginTransmission(DS1307_I2C_ADDRESS); // 255 will be the init value and 0 will be considered // an error that occurs when the RTC is in Battery mode.

Wire.endTransmission(); Wire.beginTransmission(DS1307_I2C_ADDRESS);

// load dummy values to read back I2C_WRITE(0X08); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed. I2C_WRITE(24); I2C_WRITE(0X09); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed. I2C_WRITE(52); I2C_WRITE(0X0A); // Set the register pointer to 33 for second half of registers. Only 32 writes per connection allowed. I2C_WRITE(200);

The random() function will return a pseudo-random number. For most purposes, that is good enough. The whole topic of true random numbers has been beaten to death here, so I won't go into all that you have to do to get true random numbers. Or, how to properly seed the random number generator.