کد:
$regfile = "m16def.dat"
$crystal = 8000000
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db7 = Porta.0 , Db6 = Porta.1 , Db5 = Porta.2 , Db4 = Porta.3 , E = Porta.4 , Rs = Porta.5
Config Debounce = 30
Config Clock = Soft
Config Date = Ymd
Dim T As Byte , D As Byte
'-----------------------------------------
Dim A As Long
Dim Hafteh As Byte
Dim Y1 As Integer
Dim M1 As Integer
Dim D1 As Integer
M1 = _month
Y1 = _year
D1 = _day
'-----------------------------------
D = 0
Enable Interrupts
Time$ = "14:50:20"
Do
Home
Lowerline
Lcd "Date: " ; Date$
Debounce Pinb.0 , 0 , Menu
Repeat:
Loop
End
'----------------------------------------
Menu:
D = 0
Label1:
Cls
Lcd "2-Date Setting"
Do
Debounce Pinb.0 , 0 , Repeat
Debounce Pinb.1 , 0 , Dateset
Loop
'----------------------------------------
'----------------------------------------
Dateset:
Cls
Incr D
Lcd "Day: " ; _day
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Label3
Loop
Label3:
Cls
Incr D
Lcd "Month: " ; _month
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Label4
Loop
Label4:
Cls
Incr D
Lcd "Year: " ; _year
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Repeat
Loop
'-------------------------------------
Do
A = Y1 * 365
If M1 <= 6 Then : A = A +((m1 -1) * 31) + D1
End If
Hafteh = A Mod 7
Locate 3 , 2
Select Case Hafteh
Case 1 : Lcd " SAT"
Case 2 : Lcd " SUN"
Case 3 : Lcd " MON"
Case 4 : Lcd " TUE"
Case 5 : Lcd " WED"
Case 6 : Lcd " THU"
Case 7 : Lcd " FRI"
End Select
Loop
'-------------------------------------
Incdate:
If D = 1 Then
Incr _day
If _day > 31 Then
_day = 1
End If
Cls
Lcd "Day: " ; _day
Else
If D = 2 Then
Incr _month
If _month > 12 Then
_month = 1
End If
Cls
Lcd "Month: " ; _month
Else
If D = 3 Then
Incr _year
If _year > 100 Then
_year = 0
End If
Cls
Lcd "Year: " ; _year
End If
End If
End If
'----------------------------------------
Return