$regfile = "M16DEF.DAT"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5 , E = Pind.1 , Rs = Pind.0
Config Lcd = 16 * 2
Config Portb = Input
Enable Interrupts
Config Date = YMD , Separator =.
Config Clock = Soft , Gosub = Sectic
_sec = 57 : _min = 59 : _hour = 23 : _day = 32 : _month = 11 : _year = 99
Goto W
Set_ok:
Locate 1 , 10 : Lcd "set ok "
Wait 2 : Locate 1 , 10 : Lcd " "
W:
Do
Debounce Pinb.5 , 0 , Incr_sec
Loop
Incr_sec:
Do
Locate 1 , 10 : Lcd "set sec"
Debounce Pinb.5 , 0 , Incr_min : Waitms 100
If Pinb.6 = 0 Then : _sec = 0 : Waitms 400 : End If
If Pinb.7 = 0 Then : _sec = 30 : Waitms 400 : End If
Loop
Incr_min:
Do
Locate 1 , 10 : Lcd "set min" : Waitms 100
Debounce Pinb.5 , 0 , Incr_hour
If Pinb.6 = 0 Then : Incr _min: Waitms 400 : End If
If Pinb.7 = 0 Then : Decr _min : Waitms 400 : End If
Loop
Incr_hour:
Do
Locate 1 , 10 : Lcd "set hou"
Debounce Pinb.5 , 0 , Incr_day:Waitms 100
If Pinb.6 = 0 Then : Incr _hour : Waitms 400 : End If
If Pinb.7 = 0 Then : Decr _hour: Waitms 400 : End If
Loop
Incr_day:
Do
Locate 1 , 10 : Lcd "set day"
Debounce Pinb.5 , 0 , Incr_month:Waitms 100
If Pinb.6 = 0 Then : Incr _day : Waitms 400 : End If
If Pinb.7 = 0 Then : Decr _day : Waitms 400 : End If
Loop
Incr_month:
Do
Locate 1 , 10 : Lcd "set mon"
Debounce Pinb.5 , 0 , Incr_year :Waitms 100
If Pinb.6 = 0 Then : Incr _month : Waitms 400 : End If
If Pinb.7 = 0 Then : Decr _month : Waitms 400 : End If
Loop
Incr_year:
Do
Locate 1 , 10 : Lcd "set yea"
Debounce Pinb.5 , 0 , Set_ok : Waitms 100
If Pinb.6 = 0 Then : Incr _year : Waitms 400 : End If
If Pinb.7 = 0 Then : Decr _year : Waitms 400 : End If
Loop
End
Sectic:
Locate 1 , 1 : Lcd Date$ : Locate 2 , 1 : Lcd Time$
Return
مثال:
$regfile = "M16DEF.DAT"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5 , E = Pind.1 , Rs = Pind.0
Config Lcd = 16 * 2
Enable Interrupts
Cursor Off
Config Clock = Soft , Gosub = Sectic
Config Adc = Single , Prescaler = Auto
Dim Q(2) As Word
Date$ = "11/11/00"
Time$ = "02:20:00"
Start Adc
Do
Q(1) = Getadc(0)
Q(2) = Getadc(1)
Q(1) = Q(1) / 2
Q(2) = Q(2) / 2
Locate 1 , 11
Lcd "t1:" ; Q(1)
Locate 2 , 11
Lcd "t2:" ; Q(2)
Loop
End
Sectic:
Locate 1 , 1
Lcd Date$
Locate 2 , 1
Lcd Time$
Return