hola utiliza este
#include <Wire.h> //reloj
#define DS1307_I2C_ADDRESS 0x68// reloj
#include <LiquidCrystal.h>
////////////////////////////////////////////// PINES ////////////////////////
//LiquidCrystal lcd(7, 6, 5, 4, 3, 2);// YO LO TENGO ASI DESDE EL 2 HASTA EL 7 PARA LCD Y DEL 8 AL 13 LIBRES PARA CONEXIONES
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Convierte números normales decimales a BCD (binario decimal codificado)
byte decToBcd(byte val){return ( (val/10*16) + (val%10) );}
// Convierte BCD (binario decimal codificado) a números normales decimales
byte bcdToDec(byte val){return ( (val/16*10) + (val%16) );}
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
lcd.begin(16, 2);
// si desea poner en hora, active esta parte y luego vuelva a quitarla
second = 0;
minute = 3;
hour = 19;
dayOfWeek = 6;
dayOfMonth = 8;
month = 1;
year = 11;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void loop()
{
//lee el reloj
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
imphora();
delay(500);
}//////////////////// fin de loop
/////////////////////// IMPRIME HORA /////////////////////////
void imphora(){
lcd.setCursor(0, 0);
if (hour < 10) lcd.print("0");
lcd.print(hour, DEC);
lcd.print(":");
if (minute < 10) lcd.print("0");
lcd.print(minute, DEC);
lcd.print(":");
if (second < 10) lcd.print("0");
lcd.print(second, DEC);
switch (dayOfWeek)
{
case 1:
lcd.print(" Lunes "); break;
case 2:
lcd.print(" Martes "); break;
case 3:
lcd.print(" Miercol"); break;
case 4:
lcd.print(" Jueves "); break;
case 5:
lcd.print(" Viernes"); break;
case 6:
lcd.print(" Sabado "); break;
case 7:
lcd.print(" Domingo"); break;
}
lcd.setCursor(0, 1);
lcd.print(" ");
if (dayOfMonth < 10) lcd.print("0");
lcd.print(dayOfMonth, DEC);
lcd.print("/");
if (month < 10) lcd.print("0");
lcd.print(month, DEC);
lcd.print("/");
lcd.print("20");
if (year < 10) lcd.print("0");
lcd.print(year, DEC);
lcd.print(" ");}
////////////////////////////////////////////////// MODIFICA LA HORA /////////////////////////
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 a bit 7 inicia el reloj
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // Si usted quiere 12 hora am/pm usted tiene que poner el
// bit 6 (tambien tiene que cambiar readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
///////////////////////////////////////////// LEE LA HORA /////////////////////
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}