DS1307 as an alarm.

Hey olof_n!

Thanks for the reply and help!

I was looking at the code, where you have to store it in either the EEPROM or RAM of the DS1307, considering that I have multiple times that require an alarm, what would be the best way to approach this?

Looking at the code, please do guide me, since I'm still a newbie in programming. i out some comments on each line where I get confused.

void set_alarm(byte ah,byte am)
{
  write_byte(1, ah);         //ah is the hour? 
  write_byte(2, am);        //am is the minute?
}
void get_alarm()
{
  bAlarmHours=read_byte(1);        //So this part reads the data from the EEPROM?
  bAlarmMinutes=read_byte(2);
}

//Is this a new code? like as you said in your statement above, I can either use the EEPROM, or the DS1307 RAM.

byte read_byte(byte bAdress)
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);  
  Wire.write(0x08+bAdress);                   // Set the register pointer to (0x08) to read first memory byte
  Wire.endTransmission();                      
  Wire.requestFrom(DS1307_I2C_ADDRESS, 1);     // In this case only read one byte
  byte bRetVal = Wire.read();  
  return bRetVal;
}

void write_byte(byte bAdress,byte bValue)
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);  
  Wire.write(0x08+bAdress);                             // Set the register pointer to (0xf3) to write the 11th memory byte
  Wire.write(bValue);                             // Write the desired byte value
  Wire.endTransmission(); 
}

With regards to writing new values to the EEPROM without uploading new sketches, how is that done?

if I proceeded with the IF else statements, would it still be possible? Like if I add a "second" reading, and add it to the test, such as, "hour == 8 && minute == 30 && second == 01"? And just upload a new sketch every time i wanted to change the alarm times?