importas-te de testar isto:
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(9600);
pinMode(A3, OUTPUT);
analogWrite(A3, 255);
pinMode(A2, OUTPUT);
analogWrite(A2, 0);
Wire.begin();
RTC.begin();
if (RTC.isrunning()) {
RTC.adjust(DateTime(__DATE__, __TIME__));
delay(1000);
Serial.println("Data e hora ajustada com sucesso!");
if (RTC.isrunning()) {
Serial.println("e a correr!!");
} else }
Serial.println("e nao esta a correr!");
}
}
else{
Serial.println("RTC is NOT running!");
}
}
void loop () {
DateTime now = RTC.now();
Serial.print("Data e hora atual: ");
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}
Já agora quando te aparece que o relógio não está a correr, que é que aparece impresso no ecrã?
E quando diz que está a correr, o que é que aparece? Vês as horas a mexer?
Tens o relógio a funcionar com uma bateria para manter as horas a correr?
no manual diz isto:
"When cleared to 0, the oscillator is enabled. On first application of power to the device the time and date registers are typically reset to 01/01/00 01 00:00:00 (MM/DD/YY DOW HH:MM:SS). The CH bit in the seconds register will be set to a 1."
O que será o que acontece quando desligas o RTC. Se tiveres a usar uma pilha para manter a contagem do tempo, então não será isso. Mas o que eu acho estranho nesta "biblioteca" é a falta duma instrucão para iniciar e parar o RTC. Apenas ter uma a dizer que o RTC está a andar ou não é um pouco ridículo... mas adiante...
Experimenta e vê o que aparece...