Hello All!
I got a request from my daughter to build a count down timer to Christmas for two of my grandkids.
I have a few of the RTC I2C DS1307 AT24C32 Real Time Clock Modules from Ebay, (China) and thought I could use one to do it.
what I would like to do is get the date from the module and display the time left until Dec. 25th in days and hours.
But,, I am not sure how to work the math without it getting complicated.(at least or me)
I do know how to get the date and time from the module, just need help getting 2 + 2 not to equal 6
I have looked on the forum but my searches don't seem to return anything that applies to my project.
Any help would be greatly appreciated!
Below is the code I am working with so far
Thanks
Check_Time:
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte 'SETS UP THE TIME TEMP MODULE
readi2c 0, (b23,b24,b25,b26,b27,b28,b29) 'READS THE TIME TEMP MODULE
PM_AM ="P" : IF b25 < $12 then M_AM = "A" : ENDIF 'MATH TO SET CORRECT TIME INDICATOR PM or AM
IF b25 = $20 OR b25 = $21 THEN : LET b25 = b25 - $6 : ENDIF
IF b25 > $12 THEN : LET b25 = b25 - $12 : ENDIF '24 to 12 hour format
IF b25 = $0 THEN : b25 = $12 : ENDIF
'pause 200
bcdtoascii b23,b40,b41 'Secs Convert to ASCII
bcdtoascii b24,b30,b31 'Mins
bcdtoascii b25,b32,b33 'Hours b42 shows clock time to chage to military substitue b25 for b42
bcdtoascii b26,b42,b43 'DayOfWeek;
bcdtoascii b27,b34,b35 'Date
bcdtoascii b28,b36,b37 'Month
bcdtoascii b29,b38,b39 'Year
SEROUT LCD,LCD_Baud,(254,128,b32,b33,":",b30,b31,b23,"M ",b36,b37,"/",b34,b35,"/",b38,b39) 'SENDS TIME TO LCD
if b36 = 49 and b37 = 50 and b34 = 50 and b35 = 53 then '"b" veriable numeric equiverants,,48=0,49=1,50=2,51=3,52=4,53=5,54=6,55=7,56=8,57=9
serout Lcd,lcd_baud,(254,192,"Merry Christmas")
PAUSE 200
ENDIF
goto Check_Time
return
I got a request from my daughter to build a count down timer to Christmas for two of my grandkids.
I have a few of the RTC I2C DS1307 AT24C32 Real Time Clock Modules from Ebay, (China) and thought I could use one to do it.
what I would like to do is get the date from the module and display the time left until Dec. 25th in days and hours.
But,, I am not sure how to work the math without it getting complicated.(at least or me)
I do know how to get the date and time from the module, just need help getting 2 + 2 not to equal 6
I have looked on the forum but my searches don't seem to return anything that applies to my project.
Any help would be greatly appreciated!
Below is the code I am working with so far
Thanks
Check_Time:
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte 'SETS UP THE TIME TEMP MODULE
readi2c 0, (b23,b24,b25,b26,b27,b28,b29) 'READS THE TIME TEMP MODULE
PM_AM ="P" : IF b25 < $12 then M_AM = "A" : ENDIF 'MATH TO SET CORRECT TIME INDICATOR PM or AM
IF b25 = $20 OR b25 = $21 THEN : LET b25 = b25 - $6 : ENDIF
IF b25 > $12 THEN : LET b25 = b25 - $12 : ENDIF '24 to 12 hour format
IF b25 = $0 THEN : b25 = $12 : ENDIF
'pause 200
bcdtoascii b23,b40,b41 'Secs Convert to ASCII
bcdtoascii b24,b30,b31 'Mins
bcdtoascii b25,b32,b33 'Hours b42 shows clock time to chage to military substitue b25 for b42
bcdtoascii b26,b42,b43 'DayOfWeek;
bcdtoascii b27,b34,b35 'Date
bcdtoascii b28,b36,b37 'Month
bcdtoascii b29,b38,b39 'Year
SEROUT LCD,LCD_Baud,(254,128,b32,b33,":",b30,b31,b23,"M ",b36,b37,"/",b34,b35,"/",b38,b39) 'SENDS TIME TO LCD
if b36 = 49 and b37 = 50 and b34 = 50 and b35 = 53 then '"b" veriable numeric equiverants,,48=0,49=1,50=2,51=3,52=4,53=5,54=6,55=7,56=8,57=9
serout Lcd,lcd_baud,(254,192,"Merry Christmas")
PAUSE 200
ENDIF
goto Check_Time
return
Last edited: