Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void rtc_setCG(byte val);
- const byte rtc_id = 0x68; //DS1307 i2c id: 0x68h, 104 dec, 150 octal, 1101000b
- pinMode(2, INPUT_PULLUP);
- attachInterrupt (digitalPinToInterrupt(2), rtcout_int, FALLING);
- void rtcout_int ()
- { char buf[5] = " ";
- time_t now;
- struct tm *ts;
- wdt_reset();
- noInterrupts();
- epoque++; //this is a global volatile unsigned long variable that holds the number of seconds since the arduino epoque
- interrupts();
- }
- void rtc_setCG(byte val)
- { Wire.beginTransmission(rtc_id);
- Wire.write((byte)0x07);
- Wire.write(val);
- Wire.endTransmission();
- }
- ISR (TIMER1_COMPA_vect)
- { byte nsecond;
- nsecond=(byte)((millis()/1000) % 60);
- if ( nsecond != second )
- { second=nsecond;
- epoque++;
- minute=(byte)((epoque / 60) % 60);
- hour=(byte)(((epoque / 3600) + timezone) % 24);
- }
- }
- rtc_setCG(0x10); //this is how I set up the ds1307 to do 1hz on the SQW/OUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement