Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DS1307.h> // Biblioteca DS1307 http://www.rinkydinkelectronics.com/library.php?id=34
- DS1307 rtc(SDA, SCL); // Inicialize o DS1307
- char buffer[50]; // Buffer de impressao
- //------------------------------------------------------------
- void setup()
- {
- Serial.begin(115200); // Inicialize o serial
- rtc.begin(); // Inicia o objeto RTC
- rtc.halt(false); // Define run-mode
- }
- //------------------------------------------------------------
- void loop()
- {
- Time myclock = rtc.getTime(); // Instancia o objeto myClock e obtem o horario
- int myHour = myclock.hour; // Seleciona a hora
- int myMin = myclock.min; // Seleciona o minuto
- int mySec = myclock.sec; // Seleciona o segundo
- // Carrega no buffer e imprime o buffer
- sprintf(buffer, " %02d:%02d:%02d", myHour, myMin, mySec), Serial.println(buffer);
- delay (1000); // Aguarda um segundo
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement