Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "RTClib.h"
- #include <LiquidCrystal.h>
- RTC_DS1307 RTC;
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup (){
- Serial.begin(9600);
- 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 agora = RTC.now();
- String relogio_data = ("DT: ");
- String relogio_hora = ("hr: ");
- int dia = agora.day();
- int mes = agora.month();
- int ano = agora.year();
- relogio_data += dia;
- relogio_data += "/";
- relogio_data += mes;
- relogio_data += "/";
- relogio_data += ano;
- int hora= agora.hour();
- int minuto = agora.minute();
- int segundo = agora.second();
- relogio_hora += hora;
- relogio_hora += "/";
- relogio_hora += minuto;
- relogio_hora += "/";
- relogio_hora += segundo;
- lcd.setCursor(0, 0);
- lcd.print(relogio_data);
- lcd.setCursor(0, 1);
- lcd.print(relogio_hora);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement