/*
https://github.com/NeiroNx/RTCLib
A library that makes interfacing
DS1302, DS1307, DS3231, PCF8583, PCF8563,
RTC_Millis Real Time Clock modules easy.
https://github.com/avishorp/TM1637
Arduino library for TM1637 (LED Driver)
*/
#include <RTClib.h>
#include "TM1637Display.h"
#define CLK1 9
#define DIO1 10
#define CLK2 11
#define DIO2 12
// DS1302 rtc(ce_pin, sck_pin, io_pin);
DS1302 rtc(5, 7, 6);
TM1637Display display1(CLK1, DIO1);
TM1637Display display2(CLK2, DIO2);
uint8_t prev_second;
const char data[] = "Hello World";
void setup()
{
rtc.begin();
Serial.begin(115200);
display1.setBrightness(7);
display2.setBrightness(7);
rtc.adjust(DateTime(__DATE__, __TIME__));
for (int i = 0; i < 11; ++i)
{
rtc.writeram(i, data[i]);
}
}
void loop()
{
DateTime now = rtc.now();
if (now.second() != prev_second)
{
prev_second = now.second();
char buf[20];
uint8_t ram[DS1302_RAMSIZE];
for (int i = 0; i < 11; ++i)
{
ram[i] = rtc.readram(i);
}
Serial.print((const char*)ram);
Serial.print(' ');
Serial.println(now.tostr(buf));
}
display1.showNumberDec(now.hour(), 0x80, 2, 2);
display2.showNumberDecEx(now.minute(), 0x80, 2, 2);
display2.showNumberDecEx(now.second(), 0x80, true, 2, 2);
delay(100);
}