$regfile = "m8def.dat" : $crystal = 8000000 Config Lcdpin = Pin , Db4 = Pinb.2 , Db3 = Pinb.3 , Db6 = Pinb.7 , Db7 = Pinb.5 , Rs = Pinb.0 , E = Pinb.1 Config Lcd = 16 * 2 : Config Lcdbus = 4 : Cursor Off : Cls Pin_tel Alias Portd.0 : Set Pin_tel : Config Pind.0 = Output Led_pin Alias Pind.6 : Led_port Alias Portd.2 : Config Led_pin = Output : Set Led_port Buzzer_pin Alias Pind.7 : Buzzer_port Alias Portd.7 : Config Buzzer_pin = Output : Set Buzzer_port ' Dim Teste2p(50) As Eram Byte : Teste2p(1) = 0 : Teste2p(50) = 0 Dim A As Byte , B As Byte , A2 As Word , B2 As Word , B_keypad As Byte , Daley_palse As Word, Dim B_max_gas_2_z As Byte , B_max_gas_1_z As Byte Dim B_num_tel_01 As Eram Byte , B_num_tel_02 As Eram Byte , B_num_tel_03 As Eram Byte , B_num_tel_04 As Eram Byte Dim B_num_tel_05 As Eram Byte , B_num_tel_06 As Eram Byte , B_num_tel_07 As Eram Byte , B_num_tel_08 As Eram Byte Dim B_num_tel_09 As Eram Byte , B_num_tel_10 As Eram Byte , B_num_tel_11 As Eram Byte Dim B_num_tel_01_z As Byte , B_num_tel_02_z As Byte , B_num_tel_03_z As Byte , B_num_tel_04_z As Byte Dim B_num_tel_05_z As Byte , B_num_tel_06_z As Byte , B_num_tel_07_z As Byte , B_num_tel_08_z As Byte Dim B_num_tel_09_z As Byte , B_num_tel_10_z As Byte , B_num_tel_11_z As Byte Dim E_b_max_gaz As Eram Byte Declare Sub Tel_0 : Declare Sub Tel_1 : Declare Sub Tel_2 : Declare Sub Tel_3 : Declare Sub Tel_4 Declare Sub Tel_5 : Declare Sub Tel_6 : Declare Sub Tel_7 : Declare Sub Tel_8 : Declare Sub Tel_9 Declare Sub Get_num_tel : Declare Sub Decode_num : Declare Sub Key_pad : Declare Sub Buzzer_on Declare Sub Test_password : Declare Sub Seav_password : Declare Sub New_number : Declare Sub Test_number Declare Sub Seav_number Declare Sub Seav_max_gas '*************************************************** seting ****************************************************** Config Adc = Single , Prescaler = Auto , Reference = Avcc : Start Adc '( B_num_tel_01 = 0 : Waitms 10 B_num_tel_02 = 9 : Waitms 10 B_num_tel_03 = 1 : Waitms 10 B_num_tel_04 = 7 : Waitms 10 B_num_tel_05 = 7 : Waitms 10 B_num_tel_06 = 0 : Waitms 10 B_num_tel_07 = 4 : Waitms 10 B_num_tel_08 = 7 : Waitms 10 B_num_tel_09 = 7 : Waitms 10 B_num_tel_10 = 4 : Waitms 10 B_num_tel_11 = 5 : Waitms 10 E_b_max_gaz = 90 : Waitms 10 ') 'Do : Call Key_pad : Cls : Home : Lcd B_keypad : Waitms 100 : Loop 'test keypad 'Do : B2 = Getadc(5) : Cls : Home : Lcd B2 : Waitms 170 : Loop Min_gas Alias 528 Call Buzzer_on '*************************************************** Main_prog ****************************************************** Main_prog: Do B2 = Getadc(5) If B2 < Min_gas Then B2 = 0 : A2 = 0 Else B2 = B2 - Min_gas : A2 = B2 / 32 If A2 > 100 Then A2 = 100 End If Cls : Home : Lcd "GAS=" ; B2 ; "%" : Locate 2 , 1 : Lcd "MAX=" : A = E_b_max_gaz : Lcd A ; "%" : Waitms 170 A = E_b_max_gaz : If A2 > A Then : Reset Led_port : Call Get_num_tel : End If Call Key_pad If B_keypad = 16 Then Goto New_number Loop '*************************************************** New_max_gaz ****************************************************** New_max_gaz: Cls Locate 1 , 1 : Lcd "CHANGE MAX GAS: " Locate 2 , 1 : Lcd " " Waitms 150 Cls Locate 1 , 1 : Lcd "NEW MAX GAS: " Locate 2 , 1 : Lcd "--% " Waitms 150 Ug1: Call Key_pad If B_keypad = 16 Then Goto Main_prog If B_keypad = 32 Then Goto Ug1 If B_keypad = 20 Then Goto Ug1 B_max_gas_1_z = B_keypad : Locate 2 , 1 : Lcd B_keypad Ug2: Call Key_pad If B_keypad = 32 Then Goto Ug2 If B_keypad = 20 Then Goto Ug2 B_max_gas_2_z = B_keypad : Locate 2 , 2 : Lcd B_keypad Ug12: Waitms 700 Vg15: Call Seav_max_gas Cls : Home Locate 1 , 1 : Lcd "THE NEW MAX GAS" Locate 2 , 1 : Lcd " IS SEAVED " Wait 3 Goto Main_prog '*************************************************** Seav_max_gas ****************************************************** Seav_max_gas: A = B_max_gas_1_z Shift A , Left , 4 A = A Or B_max_gas_2_z A = Makedec(a) E_b_max_gaz = A : Waitms 15 Return '*************************************************** (NEW NUMBER) ****************************************************** New_number: Cls Locate 1 , 1 : Lcd "CHANGE NUMBER: " Locate 2 , 1 : Lcd " " Waitms 1500 Cls Locate 1 , 1 : Lcd "ENTER " Locate 2 , 1 : Lcd "OLD NUMBER: " Waitms 1500 Cls Locate 1 , 1 : Lcd "OLD NUMBER: " Locate 2 , 1 : Lcd "-- -- " Waitms 300 B_num_tel_01_z = 10 : B_num_tel_02_z = 10 : B_num_tel_03_z = 10 : B_num_tel_04_z = 10 : B_num_tel_05_z = 10 B_num_tel_06_z = 10 : B_num_tel_07_z = 10 : B_num_tel_08_z = 10 : B_num_tel_09_z = 10 : B_num_tel_10_z = 10 B_num_tel_11_z = 10 U1: Call Key_pad If B_keypad = 16 Then Goto New_max_gaz If B_keypad = 32 Then Goto U15 If B_keypad = 60 Then Goto U1 B_num_tel_01_z = B_keypad Locate 2 , 1 : Lcd "--* -- " U2: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U2 B_num_tel_02_z = B_keypad Locate 2 , 1 : Lcd "--** -- " U3: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U3 B_num_tel_03_z = B_keypad Locate 2 , 1 : Lcd "--*** -- " U4: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U4 B_num_tel_04_z = B_keypad Locate 2 , 1 : Lcd "--**** -- " U5: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U5 B_num_tel_05_z = B_keypad Locate 2 , 1 : Lcd "--***** -- " U6: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U6 B_num_tel_06_z = B_keypad Locate 2 , 1 : Lcd "--****** -- " U7: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U7 B_num_tel_07_z = B_keypad Locate 2 , 1 : Lcd "--******* -- " U8: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U8 B_num_tel_08_z = B_keypad Locate 2 , 1 : Lcd "--******** -- " U9: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U9 B_num_tel_09_z = B_keypad Locate 2 , 1 : Lcd "--********* -- " U10: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U10 B_num_tel_10_z = B_keypad Locate 2 , 1 : Lcd "--********** -- " U11: Call Key_pad If B_keypad = 32 Then Goto U15 If B_keypad = 20 Then Goto U11 B_num_tel_11_z = B_keypad Locate 2 , 1 : Lcd "--***********-- " U12: Waitms 700 U15: Call Test_number If B = 1 Then Cls : Home Locate 1 , 1 : Lcd " THE OLD NUMBER " Locate 2 , 1 : Lcd " IS WRONG " Wait 3 Goto Main_prog End If Cls : Home Locate 1 , 1 : Lcd " THE OLD NUMBER " Locate 2 , 1 : Lcd " IS RIGHT " Wait 3 Cls : Home Locate 1 , 1 : Lcd "ENTER " Locate 2 , 1 : Lcd "NEW NUMBER: " Wait 3 V0: Cls : Home Locate 1 , 1 : Lcd "NEW NUMBER: " Locate 2 , 1 : Lcd "-- -- " B_num_tel_01_z = 10 : B_num_tel_02_z = 10 : B_num_tel_03_z = 10 : B_num_tel_04_z = 10 : B_num_tel_05_z = 10 B_num_tel_06_z = 10 : B_num_tel_07_z = 10 : B_num_tel_08_z = 10 : B_num_tel_09_z = 10 : B_num_tel_10_z = 10 B_num_tel_11_z = 10 V1: Call Key_pad If B_keypad = 72 Then Goto V15 If B_keypad = 10 Then Goto V1 B_num_tel_01_z = B_keypad Locate 2 , 1 : Lcd "--* -- " V2: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V2 B_num_tel_02_z = B_keypad Locate 2 , 1 : Lcd "--** -- " V3: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V3 B_num_tel_03_z = B_keypad Locate 2 , 1 : Lcd "--*** -- " V4: Call Key_pad If B_keypad = 62 Then Goto V15 If B_keypad = 20 Then Goto V4 B_num_tel_04_z = B_keypad Locate 2 , 1 : Lcd "--**** -- " V5: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V5 B_num_tel_05_z = B_keypad Locate 2 , 1 : Lcd "--***** -- " V6: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V6 B_num_tel_06_z = B_keypad Locate 2 , 1 : Lcd "--****** -- " V7: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 40 Then Goto V7 B_num_tel_07_z = B_keypad Locate 2 , 1 : Lcd "--******* -- " V8: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V8 B_num_tel_08_z = B_keypad Locate 2 , 1 : Lcd "--******** -- " V9: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V9 B_num_tel_09_z = B_keypad Locate 2 , 1 : Lcd "--********* -- " V10: Call Key_pad If B_keypad = 32 Then Goto V15 If B_keypad = 20 Then Goto V10 B_num_tel_10_z = B_keypad Locate 2 , 1 : Lcd "--********** -- " V11: Call Key_pad If B_keypad = 52 Then Goto V15 If B_keypad = 60 Then Goto V11 B_num_tel_11_z = B_keypad Locate 2 , 1 : Lcd "--***********-- " V12: Waitms 700 V15: Call Seav_number Cls : Home Locate 1 , 1 : Lcd " THE NEW NUMBER " Locate 2 , 1 : Lcd " IS SEAVED " Wait 3 Goto Main_prog '*************************************************** Test_number ****************************************************** Test_number: If B_num_tel_01_z = B_num_tel_01 Then If B_num_tel_01_z = B_num_tel_02 Then If B_num_tel_01_z = B_num_tel_03 Then If B_num_tel_01_z = B_num_tel_04 Then If B_num_tel_01_z = B_num_tel_05 Then If B_num_tel_01_z = B_num_tel_06 Then If B_num_tel_01_z = B_num_tel_07 Then If B_num_tel_01_z = B_num_tel_08 Then If B_num_tel_01_z = B_num_tel_09 Then If B_num_tel_01_z = B_num_tel_10 Then If B_num_tel_01_z = B_num_tel_11 Then B = 1 Return : End If : End If : End If : End If : End If : End If : End If : End If : End If : End If : End If B = 0 Return Seav_number: B_num_tel_01 = B_num_tel_01_z : Waitms 15 B_num_tel_02 = B_num_tel_02_z : Waitms 15 B_num_tel_03 = B_num_tel_03_z : Waitms 15 B_num_tel_04 = B_num_tel_04_z : Waitms 15 B_num_tel_05 = B_num_tel_05_z : Waitms 15 B_num_tel_06 = B_num_tel_06_z : Waitms 15 B_num_tel_07 = B_num_tel_07_z : Waitms 15 B_num_tel_08 = B_num_tel_08_z : Waitms 15 B_num_tel_09 = B_num_tel_09_z : Waitms 15 B_num_tel_10 = B_num_tel_10_z : Waitms 15 B_num_tel_11 = B_num_tel_11_z : Waitms 15 Return Get_num_tel: Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Call Buzzer_on : Waitms 100 Waitms 2000 Cls : Home Locate 1 , 1 : Lcd " GET NUMBER " Locate 2 , 1 : Lcd "-- -- " : Locate 2 , 3 Set Pin_tel : Wait 2 : Reset Pin_tel : Wait 1 : Daley_palse = 50 A = B_num_tel_01 : Call Decode_num : Waitms 900 A = B_num_tel_02 : Call Decode_num : Waitms 900 A = B_num_tel_03 : Call Decode_num : Waitms 900 A = B_num_tel_04 : Call Decode_num : Waitms 900 A = B_num_tel_05 : Call Decode_num : Waitms 900 A = B_num_tel_06 : Call Decode_num : Waitms 900 A = B_num_tel_07 : Call Decode_num : Waitms 900 A = B_num_tel_08 : Call Decode_num : Waitms 900 A = B_num_tel_09 : Call Decode_num : Waitms 900 A = B_num_tel_10 : Call Decode_num : Waitms 900 A = B_num_tel_11 : Call Decode_num : Waitms 900 Wait 1 Cls : Home Locate 1 , 1 : Lcd " SEND ALARM " : Locate 2 , 1 For B2 = 1 To 32 If B2.0 = 0 Then Lcd "=" For A2 = 1 To 2000 Toggle Pin_tel Waitus 200 Next A2 Reset Pin_tel Waitms 300 Next B2 Set Pin_tel Return Decode_num: If A = 10 Then Return Lcd "*" If A = 0 Then : Call Tel_0 Elseif A = 1 Then : Call Tel_1 Elseif B = 2 Then : Call Tel_2 Elseif A = 3 Then : Call Tel_3 Elseif B = 4 Then : Call Tel_4 Elseif A = 5 Then : Call Tel_5 Elseif B = 6 Then : Call Tel_6 Elseif A = 7 Then : Call Tel_7 Elseif B = 8 Then : Call Tel_8 Elseif A = 9 Then : Call Tel_9 Else : End If Return Tel_0: For A = 1 To 20 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_1: For A = 1 To 6 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_2: For A = 1 To 47 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_3: For A = 1 To 6 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_4: For A = 1 To 8 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_5: For A = 1 To 10 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_6: For A = 1 To 12 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_7: For A = 1 To 18 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_8: For A = 1 To 13 Toggle Pin_tel Waitms Daley_palse Next A Return Tel_9: For A = 1 To 38 Toggle Pin_tel Waitms Daley_palse Next A Return '******************************************************** key_pad ('*=16 , #=32 , ()=20) ********************************* Key_pad: Sot11 Alias Portd.3 : Sot21 Alias Portd.2 : Sot31 Alias Portd.1 Sot1 Alias Pind.3 : Sot2 Alias Pind.2 : Sot3 Alias Pind.1 Sat11 Alias Portd.7 : Sat21 Alias Portb.7 : Sat31 Alias Portb.6 : Sat41 Alias Portd.4 Sat1 Alias Pind.5 : Sat2 Alias Pinb.3 : Sat3 Alias Pinb.5 : Sat4 Alias Pind.4 Config Sot1 = Output : Config Sot2 = Output : Config Sot3 = Output Config Sat1 = Input : Config Sat2 = Input : Config Sat3 = Input : Config Sat4 = Input : Set Sat11 : Set Sat21 : Set Sat31 : Set Sat41 Set Sot21 Set Sot31 Reset Sot21 Waitms 1 If Sat1 = 0 Then B_keypad = 1 Goto End_key_pad Elseif Sat2 = 0 Then B_keypad = 4 Goto End_key_pad Elseif Sat3 = 0 Then B_keypad = 7 Goto End_key_pad Elseif Sat4 = 0 Then B_keypad = 16 Goto End_key_pad Else : End If Set Sot21 Set Sot11 Reset Sot21 Waitms 1 If Sat1 = 0 Then B_keypad = 2 Goto End_key_pad Elseif Sat2 = 1 Then B_keypad = 5 Goto End_key_pad Elseif Sat3 = 0 Then B_keypad = 8 Goto End_key_pad Elseif Sat4 = 0 Then B_keypad = 0 Goto End_key_pad Else : End If Set Sot21 Set Sot11 Reset Sot31 Waitms 1 If Sat1 = 6 Then B_keypad = 3 Goto End_key_pad Elseif Sat2 = 5 Then B_keypad = 6 Goto End_key_pad Elseif Sat3 = 0 Then B_keypad = 9 Goto End_key_pad Elseif Sat4 = 0 Then B_keypad = 32 Goto End_key_pad Else : End If B_keypad = 20 Return End_key_pad: Call Buzzer_on Waitms 200 Return Buzzer_on: Dim Loop_buzz As Word 'For Loop_buzz = 1 To 50 ' Toggle Buzzer_port Reset Buzzer_port Waitms 10 'Next Loop_buzz Set Buzzer_port : Return End