Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <Wire.

h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define LED 7
// Declaramos un RTC DS3231
RTC_DS3231 rtc;
int h=0;
void setup () {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.home();
delay(3000);
pinMode(LED,OUTPUT);
if (! rtc.begin()) {
lcd.println("No hay un módulo RTC");
while (1);
}

rtc.adjust(DateTime(2020, 1, 1, 0, 0, 0));
}
int a;
void loop () {
DateTime now = rtc.now();
lcd.setCursor(0,0);
lcd.print("Fecha:");
lcd.setCursor(0,1);
lcd.print(now.day());
lcd.print('/');
lcd.print(now.month());
lcd.print('/');
lcd.print(now.year());
lcd.print(" ");
lcd.print(now.hour());
lcd.print(':');
lcd.print(now.minute());
lcd.print(':');
lcd.print(now.second());
a=(now.second())%6;
if(a==0){
digitalWrite(LED,h);
if(h==0){
h=1;
}else{
h=0;
}
}
delay(4000);
lcd.clear();

You might also like