Need help adding DS3231 RTC to my binary clock
this new 24-hour, arduino uno binary clock. features nice french arcitecture , circuitry dual transistor constant current setup 1 watt, 350ma leds. clock made of mdf. if interested, can post electrical schematics.
i add ds3231 rtc module can keep better time.
i have included latest revision of code. not sure how remove "millis" thing , integrate ds3231 code. please help. many in advance.
cheers.
here led layout project:
i add ds3231 rtc module can keep better time.
i have included latest revision of code. not sure how remove "millis" thing , integrate ds3231 code. please help. many in advance.
cheers.
here led layout project:
code: [select]
/*
an open-source binary clock arduino.
based on code rob faludi (http://www.faludi.com)
code under (cc) lucas berbesson
http://creativecommons.org/license/cc-gpl
*/
#include <ds3231.h>
// init ds3231 using hardware interface
ds3231 rtc(sda, scl);
// init time-data structure
time t;
int second=0, minute=0, hour=0; //start time on 00:00:00
int munit,hunit,minutetens,hourtens,valm=0,valh=0,ledstats,i;
// leds positions matrix
int leds[4][4] = {
{17,1,17,0},
{17,13,2,3},
{10,9,7,4},
{11,12,8,5}
};
void setup() {
//set outputs
for(int k=0;k<=13;k++) {
pinmode(k, output);
digitalwrite(k, low);
}
pinmode(a1, input);
pinmode(a2, input);
rtc.begin();
}
void loop() {
t = rtc.gettime();
second = t.sec;
minute = t.min;
hour = t.hour;
munit = minute%10; //sets variable munit , hunit unit digits
hunit = hour%10;
minutetens = (int)(minute/10);
hourtens = (int)(hour/10);
//minutes units
if(munit & 1) { digitalwrite(leds[3][3], high);} else { digitalwrite(leds[3][3],low);}
if(munit & 2) {digitalwrite(leds[2][3], high);} else {digitalwrite(leds[2][3],low);}
if(munit & 4) {digitalwrite(leds[1][3], high);} else {digitalwrite(leds[1][3],low);}
if(munit & 8) {digitalwrite(leds[0][3], high);} else {digitalwrite(leds[0][3],low);}
//minutes
if(minutetens & 1) {digitalwrite(leds[3][2], high);} else {digitalwrite(leds[3][2],low);}
if(minutetens & 2) {digitalwrite(leds[2][2], high);} else {digitalwrite(leds[2][2],low);}
if(minutetens & 4) {digitalwrite(leds[1][2], high);} else {digitalwrite(leds[1][2],low);}
//hour units
if(hunit & 1) {digitalwrite(leds[3][1], high);} else {digitalwrite(leds[3][1],low);}
if(hunit & 2) {digitalwrite(leds[2][1], high);} else {digitalwrite(leds[2][1],low);}
if(hunit & 4) {digitalwrite(leds[1][1], high);} else {digitalwrite(leds[1][1],low);}
if(hunit & 8) {digitalwrite(leds[0][1], high);} else {digitalwrite(leds[0][1],low);}
//hour
if(hourtens & 1) {digitalwrite(leds[3][0], high);} else {digitalwrite(leds[3][0],low);}
if(hourtens & 2) {digitalwrite(leds[2][0], high);} else {digitalwrite(leds[2][0],low);}
valm = digitalread(a1); // add 1 minute when pressed
if(valm== high) {
minute++;
second=0;
rtc.settime(hour, minute, second);
delay(250);
}
valh = digitalread(a2); // add 1 hour when pressed
if(valh==high) {
hour++;
if (hour>24) {
hour = 0;
}
second=0;
rtc.settime(hour, minute, second);
delay(250);
}
delay(50);
}
nice clock!
Arduino Forum > Using Arduino > Project Guidance > Need help adding DS3231 RTC to my binary clock
arduino
Comments
Post a Comment