
Este es el codigo
Code:
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(9,8,13,12,11,10);
int hour;
int minute;
int second;
int month;
int dayOfWeek;
int dayOfMonth;
int year;
void setup()
{
Wire.begin();
lcd.begin(16,2);
}
void loop()
{
Wire.beginTransmission(104); // transmit to device #104, the ds1307
Wire.write(0x00);
Wire.endTransmission(); // stop transmitting
Wire.requestFrom(104, 7); // Solicita bytes de otro dispositivo.
second = Wire.read();
minute = Wire.read();
hour = Wire.read();
dayOfWeek = Wire.read();
dayOfMonth = Wire.read();
month = Wire.read();
year = Wire.read();
// Convertir todos los valores BCD que podrían tener "decenas" a decimal.
hour=hour/16 * 10 + hour % 16;
minute=minute/16 * 10 + minute % 16;
second=second/16 * 10 + second % 16;
dayOfMonth=dayOfMonth/16 * 10 + dayOfMonth % 16;
month=month/16 * 10 + month % 16;
year=2000 + year/16 * 10 + year % 16;
lcd.setCursor(6,0);
lcd.print(dayOfMonth);
lcd.print("/");
lcd.print(month);
lcd.print("/");
lcd.print(year);
lcd.setCursor(8,1);
lcd.print(hour);
lcd.print(":");
lcd.print(minute);
lcd.print(":");
lcd.print(second);
lcd.print(" ");
// Esto pone nombre del dia
lcd.setCursor(0,0);
switch (dayOfWeek)
{
case 1:
lcd.print("Sab"); break;
case 2:
lcd.print("Dom"); break;
case 3:
lcd.print("Lun"); break;
case 4:
lcd.print("Mar"); break;
case 5:
lcd.print("Mie"); break;
case 6:
lcd.print("Jue"); break;
case 7:
lcd.print("Vie"); break;
}
delay(1000);
}