کمک در حل مشکل برنامه ی قفل رمز دیجیتال

sam7flash

عضو جدید
سلام
آقا من یه برنامه قفل رمزی رو از یکی از دوستام گرفتم ولی مقع کامپایل 2 تا ارور میده میده لطفا کمکم کنید
این برنامه
'Compiler : Bascom1.11.7.8
$regfile = "M8DEF.DAT"
$crystal = 8000000
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 Pind.6 = Input : Program Alias Pin.6
Config Pinc.3 = Output : Speaker Alias Portc.3
Config Pind.7 = Output : Lcd_light Alias Portd.7
Config Pinc.4 = Output : Relay1 Alias Portc.4
Config Pinc.5 = Output : Relay2 Alias Portc.5
Dim Cod1 As Eram Byte , Code2 As Eram Byte , Code3 As Eram Byte
Dim Code4 As Eram Byte , Latch As Eram Byte , Delay_time As Word
Dim Password1 As Eram Byte , Password2 As Byte , Password3 As Byte,
Dim Password4 As Byte , Write_to_e2 As Eram Byte , Keypad_data As Byte
Dim Input_counter As Byte , H As Bit , Ovf_counter As Byte
Dim Delay_time_save As Eram Word
Config Kbd = Portb , Debounce = 20 , Delay = 100
'Start Of Latcher / Timer Program--------------
Config Timer0 = Timer , Prescale = 1024
'OVERFLOW:TIME=150/(8000000*256*1024)
Enable Interrupts : Enable Timer0
On Ovf0 Owerflow
'----------------------------------------------
Start_program:
If Write_to_e2 = 1 Then Goto Programing
Code1 = 2 : Waitms 10
Code2 = 2 : Waitms 10
Code3 = 2 : Waitms 10
Code4 = 2 : Waitms 10
'START OF LATCHER/TIMER PROGRAM------------------
Programing:
If Program = 1 Then Goto Input_password
Set Lcd_light
Cursor Off : Cls : Home
Lcd "IN THE NAME OF"
Locate 2 , 7 : Lcd "GOD"
Wait 4 : Cls : Home
Lcd "RELAYS ARE"
Lowerline : Lcd "LATCHER"
'-----------------------------------------------
Input_keypad1:
Keypad_data = Getkbd()
If Keypad_data > 15 Then Goto Input_keypad1
Keypad_data = Lookup(keypad_data , Data_code)
'-----------------------------------------------
Select Case Keypad_data:
'-----------------------------------------------
Case Is = 10 : H = Not H
If H = 0 Then
Cls : Home : Lcd "RELAYS ARE"
Lowerline : Lcd "LATCHER"
Latch = 0 : Waitms 10 : End If


If H = 1 Then
Cls : Home : Lcd "RELAYS ARE"
Lowerline : Lcd "TIMER"
Latch = 1 : Waitms 10 : End If
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
Sound Speaker , 1000 , 150
'------------------------------------------------
Case Is = 20
If Latch = 0 Then
Cls : Home : Lcd "OK!!RELAYS"
Lowerline : Lcd "ARE LATCHER"
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
Sound Speaker , 1000 , 150 : Wait 4
'------------------------------------------------
Goto Input_password : End If

If Latch = 1 Then
Cls : Home : Lcd "OK!!RELAYS"
Lowerline : Lcd "ARE LATCHER"
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
Sound Speaker , 1000 , 150 : Wait 4
'------------------------------------------------
Goto Input_time : End If
'------------------------------------------------
End Select
'------------------------------------------------
Waitms 200
Goto Input_keypad1
'END OF DELAY / TIMER PROGRAM -------------------
'START OF DELAY TIMER PROGRAM -------------------
Input_time:
Cls : Home : Lcd "ENTER DELAY TIME"
Lowerline : Lcd "TIME IS" ; Delay_time ; "ms"
'------------------------------------------------
Input_keypad2:
Keypad_data = Getkbd()
If Keypad_data > 15 Then Goto Input_keypad2
Keypad_data = Lookup(keypad_data , Data_code)
'------------------------------------------------
Select Case Keypad_data:
'------------------------------------------------
Case Is = 40
If Delay_time < 65530 Then Delay_time = Delay_time + 10
Waitms 10
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Sound Speaker , 100 , 150
Case Is = 50
If Delay_time >= 10 Then Delay_time = Delay_time - 10
Waitms 10
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Sound Speaker , 100 , 150
Case Is = 20
Cls : Home : Lcd "OK DELAY TIME"
Lowerline : Lcd "IS" ; Delay_time ; "ms:"
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Sound Speaker , 1000 , 150
Delay_time_save = Delay_time
Wait 4 : Goto Input_password
'------------------------------------------------
End Select
'------------------------------------------------
Waitms 200
Goto Input_time


'END OF DELAY TIME PROGRAM-----------------------
'START OF INPUT PASSWORD PROGRAM-----------------
Input_password:
Cursor Off : Cls
Home : Lcd "ENTER ACCESS"
Lowerline : Lcd "CODE"
'------------------------------------------------
Input_keypad3:
Keypad_data = Getkbd()
If Keypad_data > 15 Then Goto Input_keypad3
Keypad_data = Lookup(keypad_data , Data_code)
If Keypad_data = 30 Then Goto Change_code
If Keypad_data >= 10 Then Goto Input_keypad3
'------------------------------------------------
Incr Input_counter
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Select Case Input_couter:
'------------------------------------------------
Case Is = 1 : Password1 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline : Lcd "CODE" ; "*"

Case Is = 2 : Password2 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline : Lcd "CODE" ; "*" ; "*"


Case Is = 3 : Password3 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline : Lcd "CODE" ; "*" ; "*" ; "*"


Case Is = 4 : Password4 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline : Lcd "CODE" ; "*" ; "*" ; "*" ; "*"
Input_counter = 0
Goto Compare_match
'-------------------------------------------------
End Select
'-------------------------------------------------
Sound Speaker , 100 , 150
Waitms 200
Goto Input_keypad3
'END OF INPUT PASSWORD PROGRAM--------------------
'START OF COMPARE MATCH PROGRAM-------------------
Compare_match:
If Password1 <> Code1 Then Goto Error
If Password2 <> Code2 Then Goto Error
If Password3 <> Code3 Then Goto Error
If Password4 <> Code4 Then Goto Error
Sound Speaker , 100 , 150
Cls : Home : Lcd "OK!!PASSWORD"
Lowerline : Lcd "IS TRUE"
'------------------------------------------------
If Latch = 0 Then
Toggle Relay1 : Toggle Relay2 : End If
'------------------------------------------------
If Latch = 1 Then
Set Relay1 : Set Relay2
Delay_time = Delay_time_save : Waitms 10
Waitms Delay_time
Reset Relay1 : Reset Relay2 : End If
'------------------------------------------------
Wait 4
Goto Input_password
'END OF COMPARE MATCH PROGRAM--------------------
'START OF ERROR PROGRAM--------------------------
Error:
Cls : Home : Lcd "PASSWORD WRONG"
Lowerline : Lcd "PLEASE TRY AGAIN"
Sound Speaker , 1000 , 150
Wait 4 : Goto Input_password
'END OF ERROR PROGRAM----------------------------
'START OF CHANGE CODE PROGRAM--------------------
Change_code:
Cls : Home : Lcd "ARE YOU SURE"
Lowerline : Lcd "YES=9 NO=8"
'------------------------------------------------
Input_keypad4:
Keypad_data = Getkbd()
If Keypad_data > 15 Then Goto Input_keypad4
Keypad_data = Lookup(keypad_data , Data_code)
If Keypad_data > 10 Then Goto Input_keypad4
'------------------------------------------------
Select Case Keypad_data:
'------------------------------------------------
Case Is = 9
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Sound Speaker , 1000 , 150
Goto H1


Case Is = 8
'------------------------------------------------
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Input_counter = 0
Sound Speaker , 1000 , 150
Goto Input_password
'------------------------------------------------
End Select
'------------------------------------------------
Waitms 200
Goto Input_keypad4
'------------------------------------------------
H1:
Cls : Home : Lcd "REPEAT ACCESS"
Lowerline : Lcd "CODE"
Input_keypad5:
Keypad_data = Getkbd()
If Keypad_data > 15 Then Goto Input_keypad5
Keypad_data = Lookup(keypad_data , Data_code)
If Keypad_data > 10 Then Goto Input_keypad5
'------------------------------------------------
Incr Input_counter
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'------------------------------------------------
Select Case Input_counter:
'------------------------------------------------
Case Is = 1 : Password1 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline Lcd "CODE" ; "*"

Case Is = 2 : Password2 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline Lcd "CODE" ; "*" ; "*"

Case Is = 3 : Password3 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline Lcd "CODE" ; "*" ; "*" ; "*" '

Case Is = 4 : Password4 = Keypad_data
Cls : Home : Lcd "ENTER ACCESS"
Lowerline Lcd "CODE" ; "*" ; "*" ; "*" ; "*"
Input_counter = 0
If Password1 <> Code1 Then Goto Error2
If Password2 <> Code2 Then Goto Error2
If Password3 <> Code3 Then Goto Error2
If Password4 <> Code4 Then Goto Error2
Sound Speaker , 1000 , 150
Cls : Home : Lcd "OK!!PASSWORD"
Lowerline : Lcd "IS TRUE"
Wait 4 : Goto Error_new_code
'-------------------------------------------------
End Select
'-------------------------------------------------
Sound Speaker , 100 , 150
Waitms 200
Goto Input_keypad5
'START OF ERROR2 PROGRAM--------------------------
Error2:
Sound Speaker , 1000 , 150
Cls : Home : Lcd "SURRY.YOU CAN"
Lowerline : Lcd "NOT CHANGE CODE"
'END OF ERROR2 PROGRAM----------------------------
Error_new_code:
Cls : Home : Lcd "ENTER NEW"
Lowerline : Lcd "CODE"
Input_keypad6:
If Keypad_data > 15 Then Goto Input_keypad6
Keypad_data = Lookup(keypad_data , Data_code)
If Keypad_data > 10 Then Goto Input_keypad6
'-------------------------------------------------
Incr Input_counter
Stop Timer0 : Timer0 = 0 : Ovf_counter = 0
Start Timer0 : Set Lcd_light
'-------------------------------------------------
Select Case Input_counter:
'-------------------------------------------------
Case Is = 1 : Password1 = Keypad_data
Cls : Home : Lcd "ENTER NEW"
Lowerline : Lcd "CODE" ; Password1

Case Is = 2 : Password2 = Keypad_data
Cls : Home : Lcd "ENTER NEW"
Lowerline : Lcd "CODE" ; Password1 ; Password2

Case Is = 3 : Password3 = Keypad_data
Cls : Home : Lcd "ENTER NEW"
Lowerline : Lcd "CODE" ; Password1 ; Password2 ; Password3

Case Is = 4 : Password4 = Keypad_data
Cls : Home : Lcd "ENTER NEW"
Lowerline : Lcd "CODE" ; Password1 ; Password2 ; Password3 ; Password4
Incr Input_counter = 0
Code1 = Password1 : Waitms 10
Code2 = Password2 : Waitms 10
Code3 = Password3 : Waitms 10
Code4 = Password4 : Waitms 10
Write_to_e2 = 1
Sound Speaker , 1000 , 150
Wait 4 : Goto Input_password
'------------------------------------------------
End Select
'------------------------------------------------
Sound Speaker , 100 , 150
Waitms 200
Goto Input_keypad6
'END OF CHANGE CODE PROGRAM----------------------
'START OF DATA CODE LOOKUP-----------------------
Data_code:
Data 40 , 0 , 50 , 60 , 7 , 8 , 9 , 30 , 4 , 5 , 6 , 20 , 1 , 2 , 3 , 10
'END OF DATA CODE LOOKUP-------------------------
'START OF OWERFLOW PROGRAM-----------------------
Owerflow:
Incr Ovf_counter
If Ovf_counter > 150 Then
Ovf_counter = 0 : Stop Timer0
Reset Lcd_light : Timer0 = 0
End If
Return
'END OF OWERFLOW PROGRAM-------------------------
 

پیوست ها

  • New Text Document.txt
    11.6 کیلوبایت · بازدیدها: 0
بالا