'IN THE NAME OF GOD
'COMPILER:BASCOM 1.11.8.7
$regfile = "M8DEF.DAT"
$crystal = 8000000
Config Pinb.0 = Input : Inc_button Alias Pinb.0
Config Pinb.1 = Input : Dec_button Alias Pinb.1
Config Pinb.2 = Input : Ok_button Alias Pinb.2
Config Pinb.3 = Output : Speaker Alias Portb.3
Config Pind.7 = Output : Relay Alias Portd.7
Config Pind.6 = Input : Sw1 Alias Pind.6
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Pind.0 , Db5 = Pind.1 , Db6 = Pind.2 , Db7 = Pind.3_
 , E = Pind.4 , Rs = Pind.5
Config Timer2 = Timer , Async = On , Prescale = 128
Enable Timer2
Enable Ovf2
On Ovf2 Timer2_overflow
Enable Interrupts
Dim M As Byte , S As Byte , H As Byte , A As Byte , H_save As Eram Byte
Dim M_save As Eram Byte , M_compare As Byte , H_compare As Byte
'START OF PROGRAM--------------------------------------------------------------------------------------
S = 0 : M = 0 : H = 0
If Sw1 = 1 Then Goto Time_counter
'--------------------------------------------------------------------------------
Program_start:
Cursor Off : Cls : Home
Lcd "IN THE NAME OF"
Locate 2 , 7 : Lcd "GOD"
Wait 4
Cls : Home
Lcd "PLEASE ENTER"
Lowerline : Lcd "OVERFLOW TIME"
Wait 4
'-----------------------------------------------------------------------------------------------------------------------
Input_h:
Cls : Home : Lcd "PLEASE ENTER H"
Lowerline : Lcd "H=" ; H
'------------------------------------------------------------------------------
If Inc_button = 1 Then
If H < 255 Then Incr H
Sound Speaker , 100 , 150
End If
'------------------------------------------------------------------------------
If Dec_button = 1 Then
If H > 0 Then Decr H
Sound Speaker , 100 , 150
End If
'------------------------------------------------------------------------------
If Ok_button = 1 Then
Cls : Home : Lcd "OK!!"
Lowerline : Lcd "H IS=" ; H
Sound Speaker , 1000 , 150
Wait 4 : H_save = H : Waitms 10
Goto Enter_m : End If
'------------------------------------------------------------------------------
Waitms 200
Goto Input_h
'-----------------------------------------------------------------------------------------------------------------------
Enter_m:
Cls : Home : Lcd "PLEASE ENTER M"
Lowerline : Lcd "M=" ; M
'------------------------------------------------------------------------------
If Inc_button = 1 Then
If M < 59 Then Incr M
Sound Speaker , 100 , 150
End If
'------------------------------------------------------------------------------
If Dec_button = 1 Then
If M > 0 Then Decr M
Sound Speaker , 100 , 150
End If
'------------------------------------------------------------------------------
If Ok_button = 1 Then
Cls : Home : Lcd "OK!!"
Lowerline : Lcd "M IS=" ; M
Sound Speaker , 1000 , 150
Wait 4 : M_save = M : Waitms 10
Goto Time_counter : End If
'------------------------------------------------------------------------------
Waitms 200
Goto Enter_m
'-----------------------------------------------------------------------------------------------------------------------
Time_counter:
S = 0 : M = 0 : H = 0 : Cursor Off
M_compare = M_save : H_compare = H_save
'----------------------------------------------------------------------
Do
Home
Lcd "OVF TIME= " ; H_compare ; ":" ; M_compare
Lowerline : Lcd "TIME IS " ; H ; ":" ; M ; ":" ; S
'----------------------------------------------------------------------
If H = H_compare Then
If M = M_compare Then
Set Relay
Cls : Home
Lcd "TIME IS"
Lowerline : Lcd "OWERFLOW"
Disable Interrupts
Do
Sound Speaker , 1000 , 150
Waitms 100
Loop
End If : End If
'----------------------------------------------------------------------
Waitms 300
Loop
'----------------------------------------------------------------------
'END OF PROGRAM-----------------------------------------------------------------------------------------
Timer2_overflow:
Disable Interrupts
Stop Timer2
Incr S
If S > 59 Then
S = 0 : Incr M : Cls
End If
'----------------------------------------------------------------------
If M > 59 Then
Incr H : M = 0 : Cls
End If
'----------------------------------------------------------------------
If H > 250 Then
S = 0 : M = 0 : H = 1 : Cls
End If
'----------------------------------------------------------------------
Enable Interrupts
Start Timer2
Return
'-----------------------------------------------------------------------------------------------------------------------