Есть такой код #include <Wire.h> #include "DS1307.h" #include "OasisLED.h" #include <Arduino.h> #include <IRremote.h> #include <RCSwitch.h> int RECV_PIN = 11; uint8_t clockPin = 3; uint8_t strobePin = 2; uint8_t dataPin = 4; OasisLED ledDisplay = OasisLED(clockPin, strobePin, dataPin); IRrecv irrecv(RECV_PIN); decode_results results; uint8_t dout = 5; int i=0; int ky0, key1,key2,key3,key4,key5; const static uint8_t READKEY = 0x42; byte a,b,button1,button2,button3,button4,key11,key12; byte incoming; int wordd; RCSwitch mySwitch = RCSwitch(); DS1307 clock;//define a object of DS1307 class void setup() { Serial.begin(9600); pinMode(dout, INPUT_PULLUP); clock.begin(); ledDisplay.initialize(); // clock.fillByYMD(2015,3,9);//Jan 19,2013 // clock.fillByHMS(22,47,30);//15:28 30" // clock.fillDayOfWeek(SUN);//Saturday // clock.setTime();//write time to the RTC chip irrecv.enableIRIn(); // Start the receiver mySwitch.enableTransmit(10); mySwitch.setPulseLength(251); } void loop() { printTime(); delay(1000); digitalWrite(strobePin, LOW); for (uint8_t i = 0; i < 8; i++) { shiftOut(dataPin, clockPin, LSBFIRST, READKEY); } delay(1000); ky0=shiftIn(dout, clockPin, LSBFIRST); key1 = shiftIn(dout, clockPin, LSBFIRST); key2 = shiftIn(dout, clockPin, LSBFIRST); key3 = shiftIn(dout, clockPin, LSBFIRST); key4 = shiftIn(dout, clockPin, LSBFIRST); key5 = shiftIn(dout, clockPin, LSBFIRST); digitalWrite(strobePin, HIGH); key11=key1; key12=key2; button1=key11&1; button2=(key11&8)/8; button3=key12&1; button4=(key12&8)/8; // wordd=button1*1+button2*10+button3*100+button4*1000; // ledDisplay.setValue(wordd); } /*Function: Display time on the serial monitor*/ void printTime() { clock.getTime(); // Serial.print(clock.hour, DEC); // Serial.print(":"); // Serial.print(clock.minute, DEC); // Serial.print(":"); // Serial.print(clock.second, DEC); // Serial.print(" "); // Serial.print(clock.month, DEC); // Serial.print("/"); // Serial.print(clock.dayOfMonth, DEC); // Serial.print("/"); // Serial.print(clock.year+2000, DEC); // Serial.print(" "); // Serial.print(clock.dayOfMonth); // Serial.print("*"); ledDisplay.setValue(clock.hour*100+clock.minute); if(irrecv.decode(&results)) { Serial.println(results.value, HEX); if ((results.value == 0x37) || (results.value == 0x10037)) { mySwitch.send(836656,24); // если код код получен зажигаем зал } delay (500); irrecv.resume(); } } Вывожу часы на 7 сегментный индикатор, а так же реализовано управление люстрой через ик порт. Часы почему отстают на 5 минут за 2 недели (((. Как правильно реализовать: нажал buton1 - часы увеличил, нажал button2 - минуты ??? Чтение кнопок сделано.
Кварц неточный либо разводка неправильная. С каким модулем работаете? 14 дней * 24 часа * 60 минут = 20160 минут. 20160 / 5 = 4032. Можете каждые 4032 минуты добавлять минуту.
RTC 1307 вот такие http://de.shopotam.ru/catalog/Busin...rierte_Schaltungen_Ics/121242695048-item.html