فى كود بسيط
ادخل الباسورد وتشغيل جهاز
ATMEGA32 و LCD 16X2 و KEYBAD 4X4
-----------------------------------------------------
المشكلة انو الدايرة مش شغالة على برنامج البروتوس
------
الكود
كود:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' BASCOM AVR ~
' PASSWPRD ~
' ~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~START_PROGRAM~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''Var's''
Dim Keyread As Byte
Dim Key As Byte
Dim Digits As Byte
Dim Point As Byte
Dim Code As Word
Dim Mycode As Word
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''configration''
Config Portb = Output
Portb = 0
Realay Alias Portb.2
Beep Alias Portc.0
Config Kbd = Portc , Debounce = 40
Mycode = 1234
Cursor Off
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do
Begin:
Lcd "initiallizing ....."
Set Beep
Waitms 100
Reset Beep
Wait 2
Cls
Lcd "Enter Password"
Code = 0
Digits = 0
Point = 0
Do
Keyread = Getkbd()
If Keyread <> 16 Then Gosub Gotkey
Waitms 100
If Digits = 4 Then
If Code = Mycode Then
Goto Opendoor
Else
Goto Error
End If
End If
Loop
Loop
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gotkey:
Ddrc = 255
Set Beep
Waitms 100
Reset Beep
Waitms 100
Key = Lookup(keyread , Dta)
Incr Digits
Point = Digits + 6
Locate 2 , Point
Lcd "*"
Code = Code * 10
Code = Code + Key
Return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dta:
Data 7 , 8 , 9 , 255 , 4 , 5 , 6 , 255 , 1 , 2 , 3 , 255 , 255 , 0 , 255 , 255
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error:
Cls
Lcd "invalid password"
Wait 100
Set Beep
Wait 1
Reset Beep
Lowerline
Lcd "wait 10 sec"
Wait 10
Cls
Lcd "Enter password"
Goto Begin
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ok:
Waitms 100
Set Beep
Waitms 200
Reset Beep
Waitms 200
Set Beep
Waitms 200
Reset Beep
Return
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opendoor:
Cls
Lcd "pass accepted"
Gosub Ok
Lowerline
Lcd "door open"
Waitms 300
Set Realay
Wait 1
Reset Realay
Wait 1
Cls
Goto Begin
''~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
''~~~~~~~~~~~~~~~~~
ملف البروتوس والكود
http://www.gulfup.com/?mrReaD