با سلام وخسته نباشید !شرمنده من تازه شروع به اموزش دیدن avrکردم و اموزش avr از صفر تا بینهایت شمارو خوندم وبسیار متشکر!ولی متاسفانه ناقص بود!حال می خواستم برنامه زیر رو بخونم که دستورات یاد داده شده قبل کافی نبود میخواستم به صورت مختصر این برنامه رو توضیح بدین!با کمال تشکر فراوان
کد:
$regfile = "m8def.dat"
$crystal = 1000000
'#################################### CONFIG ###############################
Config Portd = Input
Config Portd.0 = Output
Config Portd.7 = Output
Config Portb.0 = Input
Config Portb.1 = Input
Config Portb.2 = Input
Config Portb.3 = Input
Config Portb.4 = Output
Config Portb.5 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Config Portc = Output
'#################################### ALIAS ###############################
Telm Alias Pind.2
Zang Alias Pind.3
Tel Alias Portd.7
Beep Alias Portd.0
'#################################### DIMS ###############################
Dim Test As Byte
Dim Pasword(4) As Byte
Dim Pastest(4) As Byte
Dim Pas(4) As Byte
Dim A As Byte
Dim B As Byte
'#################################### declare ###############################
Declare Sub Passok
Declare Sub Changepassword
'#################################### READ ROMS ###############################
Readeeprom Pasword(1) , 0
Readeeprom Pasword(2) , 1
Readeeprom Pasword(3) , 2
Readeeprom Pasword(4) , 3
'Readeeprom Zang1 , 4
'Readeeprom Zang2 , 5
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Main:
Do
If Zang = 0 Then
Waitms 100
If Zang = 0 Then
Gosub Zangset
End If
End If
Waitms 50
Loop
End
'##########################################################################
Zangset:
A = 0
For B = 1 To 120
If Zang = 0 Then
B = 1
Do
If Zang = 1 Then
Exit Do
End If
Loop
Incr A
If A >= 4 Then
Set Tel
Waitms 800
Sound Beep , 400 , 100
Sound Beep , 350 , 120
Gosub Readtel
End If
End If
Waitms 100
Next
A = 0
Sound Beep , 150 , 100
Sound Beep , 100 , 150
Return
'##########################################################################
Readtel:
A = 1
For B = 1 To 250
If Telm = 1 Then
B = 1
Pas(a) = Pinb
Incr A
While Telm = 1
Wend
Sound Beep , 150 , 100
If A >= 5 Then
Exit For
End If
End If
Waitms 100
Next
If Pas(1) = Pasword(1) And Pas(2) = Pasword(2) And Pas(3) = Pasword(3) And Pas(4) = Pasword(4) Then
Waitms 800
Passok
End If
Sound Beep , 200 , 200
Waitms 500
Sound Beep , 200 , 200
Waitms 500
Sound Beep , 200 , 200
Waitms 500
Sound Beep , 200 , 200
Reset Tel
Return
'##########################################################################
Passok:
While Telm = 1
Wend
Sound Beep , 200 , 150
Waitms 100
Sound Beep , 200 , 130
For B = 1 To 250
If Telm = 1 Then
B = 1
A = Pinb
Else
A = 0
End If
While Telm = 1
Wend
Select Case A
Case 1
Toggle Portc.0
Sound Beep , 200 , 130
Case 2
Toggle Portc.1
Sound Beep , 200 , 130
Case 3
Toggle Portc.2
Sound Beep , 200 , 130
Case 4
Toggle Portc.3
Sound Beep , 200 , 130
Case 5
Toggle Portc.4
Sound Beep , 200 , 130
Case 6
Toggle Portc.5
Sound Beep , 200 , 130
Case 11
Changepassword
Case 0
Case Else
Sound Beep , 100 , 150
Sound Beep , 100 , 120
Sound Beep , 100 , 150
Sound Beep , 100 , 120
Sound Beep , 100 , 150
Sound Beep , 100 , 120
End Select
Waitms 70
Next
Sound Beep , 100 , 150
Sound Beep , 100 , 120
Sound Beep , 100 , 150
Sound Beep , 100 , 120
Reset Tel
Goto Main
'##########################################################################
Changepassword:
While Telm = 1
Wend
Sound Beep , 100 , 150
Sound Beep , 100 , 120
A = 1
For B = 1 To 250
If Telm = 1 Then
While Telm = 1
Wend
B = 1
Pasword(a) = Pinb
Incr A
If A >= 5 Then
Exit For
End If
End If
Waitms 50
Next
Sound Beep , 400 , 100
Waitms 700
Sound Beep , 400 , 100
A = 1
For B = 1 To 250
If Telm = 1 Then
While Telm = 1
Wend
B = 1
Pastest(a) = Pinb
Incr A
If A >= 5 Then
Exit For
End If
End If
Waitms 50
Next
If Pasword(1) = Pastest(1) And Pasword(2) = Pastest(2) And Pasword(3) = Pastest(3) And Pasword(4) = Pastest(4) Then
Writeeeprom Pasword(1) , 0
Waitms 10
Writeeeprom Pasword(2) , 1
Waitms 10
Writeeeprom Pasword(3) , 2
Waitms 10
Writeeeprom Pasword(4) , 3
Waitms 500
Sound Beep , 700 , 200
Else
Sound Beep , 200 , 150
Sound Beep , 210 , 170
Sound Beep , 200 , 150
Sound Beep , 210 , 170
End If
Return
'#########################################################