Using bigger 4 one inch 7 segment displays , they are really impressive compared to the smaller 2 half inch used to display seconds.
For those wanting good time accuracy the ds3231 (ebay) is a good choice,both I2c slow 100kbps or fast 400kbps can be chosen.
The code is the same should you choose to use the ds1307 however suggest the pullup resistors be changed 2.2K.
With the power off it is backed up with a supercap expect it to last several days
I did try it without power for two days but too impatient after that lol.
The ds18b20 using the same pin as display1 ,will display the full temperature range from
(-55'C) to (125'C)and to one decimal place between (-9.9'C) to (99.9'C).
If the button is pressed while the temperature is displayed it will toggle to display fahrenheit
instead(-67'F)(-9.9'F)(99.9'F)(257'F).
If the button is pressed while the time is displayed, date and time(0-23hr format) can be programmed one digit at a time(days,months,years,hours mins).
Push to select,hold too remember,when the final selection is released the ds3231 will be programmed.Displays time in 12hr format.
Displays current temperature(26.5'C) at the 16th second and returns to time(10.23)(22)
AT the 31st second displays (29.9'C)(Hi) and then (26.2'C)(Lo) temperatures.
and lastly the date (31 )( 01)(2011) updating and returning to display time (10.23)(50).
the hi and lo temps reset at 0000 hrs.
For those wanting good time accuracy the ds3231 (ebay) is a good choice,both I2c slow 100kbps or fast 400kbps can be chosen.
The code is the same should you choose to use the ds1307 however suggest the pullup resistors be changed 2.2K.
With the power off it is backed up with a supercap expect it to last several days
I did try it without power for two days but too impatient after that lol.
The ds18b20 using the same pin as display1 ,will display the full temperature range from
(-55'C) to (125'C)and to one decimal place between (-9.9'C) to (99.9'C).
If the button is pressed while the temperature is displayed it will toggle to display fahrenheit
instead(-67'F)(-9.9'F)(99.9'F)(257'F).
If the button is pressed while the time is displayed, date and time(0-23hr format) can be programmed one digit at a time(days,months,years,hours mins).
Push to select,hold too remember,when the final selection is released the ds3231 will be programmed.Displays time in 12hr format.
Displays current temperature(26.5'C) at the 16th second and returns to time(10.23)(22)
AT the 31st second displays (29.9'C)(Hi) and then (26.2'C)(Lo) temperatures.
and lastly the date (31 )( 01)(2011) updating and returning to display time (10.23)(50).
the hi and lo temps reset at 0000 hrs.
Code:
' -- -- -- -- -- -- o -- --
'C.0-A | | | | | | | |
'C.1-B Picaxe 20x2 ver C.0
'C.2-C | | | | | | | |
'C.3-D -- -- -- -- -- -- -- -- -- --
'C.4-E | | | | | | | | | | | |
'C.5-F -- -- marks
'C.7-G | | | | | | | | | | | |
' -- -- -- -- o -- -- -- -- -- --
'B.5-SDA
'B.7-SCL
'A.0-D.P
'Display 1 2 3 4 5 6
'Common anode
SYMBOL pushbutton = PINC.6
SYMBOL ds18b20 = B.6
SYMBOL display1 = B.6
SYMBOL display2 = B.5
SYMBOL display3 = B.4
SYMBOL display4 = B.3
SYMBOL display5 = B.2
SYMBOL display6 = B.1
SYMBOL decimalpoint = A.0
SYMBOL hours = B10 'note selection uses (b0.b1,b2,b3,b4,b5)
SYMBOL mins = B11
SYMBOL secs = B12
SYMBOL day = B13
SYMBOL date = B14
SYMBOL month = B15
SYMBOL year = B16
SYMBOL character = B17
SYMBOL recall = B18
SYMBOL degrees = B19
SYMBOL push = B20
SYMBOL Hilo = b21
SYMBOL updatetime = W11 '(b22,b23)
SYMBOL totalminutes = W12 '(b24,b25)
SYMBOL displayedtime = W13 '(b26,b27)
SYMBOL temperature = W14 '(b28,b29)
SYMBOL rawtemperature= W15 ' note if changing ( b30,b31 ) change in Temperatureread.
SYMBOL hold = W16 '(b32.b33)
SYMBOL Maximum = W17 '(b34,b35)
SYMBOL Minimum = W18 '(b36,b37)
EEPROM 0, ( 63, 6 ,155,143,166,173,189, 7 ,191,175, 0 ,161,128,177,182, 16, 56,156)
'Character ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,blank, C , - , F , H , i , L , o )
SETFREQ M16
LET dirsb = %01011111
LET dirsc = %10111111
OWOUT ds18b20,%1001,($CC,$44) 'reset(send skip rom ,send convert t)
SETTIMER T1S_16
LOW decimalpoint
Maximum = 0 : Minimum = 2880
Program1:
PAUSE 10
HI2CSETUP I2CMASTER, %11010000, I2Cslow_16, I2CBYTE ' set to 100kbps default /change to I2Cfast_16 for 400kbps
PAUSE 20
HI2CIN 0,(secs,mins,hours,day,date,month,year) ' read time ds3231
HI2CSETUP OFF
Main: IF hours = $0 and mins =$0 then :Maximum = 0 : Minimum = 2880 : endif
LET date = BCDTOBIN date 'Date from ds3231 needs converting
LET month = BCDTOBIN month
LET year = BCDTOBIN year
LET secs = BCDTOBIN secs 'Time from ds3231 needs converting
LET totalminutes = BCDTOBIN mins * 60
LET hours = BCDTOBIN hours
IF hours > 12 THEN
LET updatetime = hours - 12 * 3600 + totalminutes + secs 'pm
ELSE
LET updatetime = hours * 3600 + totalminutes + secs 'am
ENDIF
LET TIMER = updatetime 'up date time from ds3231 every minute
ClockDisplay:
LOW display6
hours = TIMER /3600
character=10 : IF hours < 10 THEN dig1 'Display1 Zero blanking
LET character = hours DIG 1
READ character,pinsc : HIGH display1 : PAUSEus 70
Dig1:
IF pushbutton = 1 THEN Menu 'program
LET character = hours DIG 0
Dig2: low display1 : READ character,pinsc :HIGH decimalpoint: HIGH display2 : PAUSEus 70
mins = TIMER //3600/60
LET character = mins DIG 1 : LOW decimalpoint
Dig3: LOW display2 : READ character,pinsc : HIGH display3 : PAUSEus 70
LET character = mins DIG 0
Dig4: LOW display3 : READ character,pinsc : HIGH display4 : PAUSEus 70
secs = TIMER //3600//60
IF secs = 16 THEN gosub TemperatureDisplay
IF secs = 31 THEN dateDisplay
LET character = secs DIG 1
Dig5: LOW display4 : READ character,pinsc : HIGH display5 : PAUSEus 130
LET character = secs DIG 0
Dig6: LOW display5 : READ character,pinsc : HIGH display6 : PAUSEus 130
GOTO clockdisplay
Attachments
-
174.2 KB Views: 151
-
417.6 KB Views: 159
Last edited: