-
Notifications
You must be signed in to change notification settings - Fork 3
MarcG edited this page Feb 22, 2015
·
1 revision
Un Reloj en tiempo real(en inglés, real-time clock, RTC) es un reloj de un ordenador, incluido en un circuito integrado, que mantiene la hora actual.
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
// VCC to 5v
// SDA to A4
// SCL to A5
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}