Bascom Code: "M16def - Dat"
Bascom Code: "M16def - Dat"
$regfile = "m16def.dat"
Config Portb = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , Rs =
Portd.3 , E = Portd.2
Config Timer2 = Timer , Async = On , Prescale = 128
Config Adc = Single , Prescaler = Auto
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Secs As Byte , Minits As Byte , Hours As Byte
Dim A As Word , B As Byte
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Deflcdchar 0 , 12 , 18 , 18 , 12 , 32 , 32 , 32 , 32
Deflcdchar 1 , 32 , 4 , 12 , 28 , 28 , 32 , 32 , 32
Deflcdchar 2 , 32 , 4 , 14 , 31 , 31 , 32 , 32 , 32
Deflcdchar 3 , 32 , 4 , 14 , 31 , 31 , 7 , 6 , 4
Deflcdchar 4 , 32 , 4 , 14 , 31 , 31 , 31 , 14 , 4
Deflcdchar 5 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Start Adc
B = 1
Enable Interrupts
Enable Timer2
On Timer2 K
Start Timer2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Cls
Cursor Off
Do
Loop
End
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
K:
'''''''''''''''''''''''''''''''''''''
A = Getadc(0)
A = A / 2
Locate 2 , 1
Lcd "Temp =" ; A ; Chr(0) ; "c
"
Locate 2 , 16
Lcd Chr(b)
Incr B
If B > 6 Then B = 1
'''''''''''''''''''''''''''''''''''''
Incr Secs
If Secs > 59 Then
Incr Minits
Secs = 0
If Minits > 59 Then
Incr Hours
Minits = 0
Secs = 0
If Hours > 23 Then
Hours = 0
Secs = 0
Minits = 0
End If
End If
End If
If Pinb.2 = 1 Then
Secs = 0
Elseif Pinb.0 = 1 Then
Incr Minits
Elseif Pinb.1 = 1 Then
Incr Hours
End If
Locate 1 , 1
If Hours < 10 Then
Lcd "0" ; Hours ; ":"
Else
Lcd Hours ; ":"
End If
If Minits < 10 Then
Lcd "0" ; Minits ; ":"
Else
Lcd Minits ; ":"
End If
If Secs < 10 Then
Lcd "0" ; Secs
Else
Lcd Secs
End If
Return