51 lines
1.2 KiB
Arduino
51 lines
1.2 KiB
Arduino
|
#include <avr/power.h>
|
||
|
//#include <Wire.h>
|
||
|
#include "RTClib.h"
|
||
|
|
||
|
RTC_DS1307 rtc;
|
||
|
|
||
|
void setup() {
|
||
|
delay(4000);
|
||
|
// Serial.println("hola");
|
||
|
Serial.begin(57600);
|
||
|
if (! rtc.begin()) {
|
||
|
Serial.println("Couldn't find RTC");
|
||
|
while (1);
|
||
|
}
|
||
|
// 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(F(__DATE__), F(__TIME__)));
|
||
|
// This line sets the RTC with an explicit date & time, for example to set
|
||
|
// January 21, 2014 at 3am you would call:
|
||
|
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
|
||
|
void loop() {
|
||
|
|
||
|
DateTime now = rtc.now();
|
||
|
uint16_t minute = now.minute() + now.hour()*60;
|
||
|
// if (minute > 720) minute = minute - 720;
|
||
|
Serial.print(now.hour());
|
||
|
Serial.print(':');
|
||
|
Serial.print(now.minute());
|
||
|
Serial.print(':');
|
||
|
Serial.println(now.second());
|
||
|
delay(1000);
|
||
|
// if (minute!= minute_ant)
|
||
|
// {
|
||
|
// Serial.println(minute);
|
||
|
// piramidon_time((int)(minute/4));
|
||
|
// minute_ant = minute;
|
||
|
// }
|
||
|
|
||
|
// for (int i=0; i<720; i++)
|
||
|
// {
|
||
|
// piramidon_time(i);
|
||
|
// delay(1);
|
||
|
// }
|
||
|
|
||
|
// clear();
|
||
|
}
|