Sunteți pe pagina 1din 14

Programmable number lock system

Programmable number lock system is a high security number lock system that can
be used to lock electronic devices. The present system is very user friendly. This
system is a combination of software and hardware at its best. We have used a avr
microcontroller kit for interfacing our system.
In the present design we can activate or deactivate 9 devices. Each device is locked
using a 4 digit code (password). The code can be set as per the user’s desire, hence the
name ‘ PROGRAMMABLE ‘. For the device to be activated (unlocked), the user
should enter the code that had been entered when the device was locked. In case the
user enters the wrong code a silent alarm will be activated.

Introduction to Programmable number lock system:

The system has three units, namely:

1. Keyboard unit.
2. Display unit.
3. Control unit.

The keyboard unit consists of 9 number keys, 1 unlock key and 1 lock key. These are
all push button switches. This unit is used to select the desired device and to enter the
codes into the system. It is also used to request the system to lock/unlock the selected
device.

The display section contains 5 seven segment display. This unit displays the device
number and the code entered. This section is detachable. If detached it does not affect
the working of the whole system. This unit also contains password reset button and an
LED to indicate the error when the device is already locked and user wants to lock
the device again. The error indicator also indicates an error when the system is
already unlocked and the user tries to unlock the same.

The control unit is the heart of our system. It contains the necessary circuitry for the
control of the device .This unit controls 9 devices, which is lock/unlock by selecting
it using the keyboard and entering the password. If the code entered to unlock the
device is wrong, then a silent alarm is triggered .The keyboard unit and the display
unit are connected to this unit.

All these three units are merged together to form the whole system.
Model of Programmable number lock system

Block diagram of Programmable number lock system:


Block diagram of Programmable number lock system:

Working of the system:

When the system is initially installed the reset button is pressed. This key is present
in the control unit. This unlocks all the devices. This is to avoid undesired functioning
of the system.

To lock a particular device the device number is selected using the keyboard. Once
the device is selected the user has to press the lock key present in the keyboard. Now
the device waits for the user to enter the the code. The user can enter a 4 digit number
using the keyboard as per his desire. Once all the 4 digits are entered the system
electronically locks the selected device.

In the same manner to unlock a particular device, the device number is entered using
the keyboard. Once the device number is selected the code for the selected device is
entered. If the entered code matches the code that had been entered while that
particular device was locked then the selected device will be activated (unlocked). If
the codes do not match each other a silent alarm will be triggered (a LED placed in
the control section. Shown in figure 3).An error indicator (placed in the display
section) is provided if any user tries to lock a device which has already been locked or
vice versa.

If the user is half way entering the code or has done an error while entering the code
and wants to start over all again then a reset button is provided in the display section.
By pressing this button the user can start from entering the device number and so on.

The number of devices which the system can control can be increased by addition of a
few components in the control unit. More security can be achieved by increasing the
number of digits in the code. This can be done by minor changes in the program. The
system uses the internal RAM of the 8051 to store the code and hence puts a lower
limit to the number of digits in the code and also the number of devices the system
can control. Once the system is installed only the display unit and keyboard unit will
be accessible to the user. Access to the control unit should be provided only to an
official personal since it contains the system reset button.

Program(atmega 16 microcontroller):

"regfile = "m16def.dat$
crystal = 1000000$
Config Kbd = Portc
Config Lcd = 16 * 2
Config Porta = Output
Config Portb = Output
Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.4 , Rs
= Portb.5
Dim B1 As Byte
Dim Y(4) As Byte , Z As Byte , I As Integer
Dim X(4) As Byte 'device 1
Dim E(4) As Byte
Dim G(4) As Byte
Dim R(4) As Byte
Dim S(4) As Byte
Dim T(4) As Byte
Dim U(4) As Byte
Dim V(4) As Byte
Dim W(4) As Byte
Dim D As Integer
Dim B As Integer

###################################'
Do
Cls
"Lcd " Hellow
Waitms 1000
******'
' Gosub Sd 'select device
********'
Gosub Lu 'lock or unlock

Waitms 2000
Loop
#################################'
Sd: 'select device
Z = 16
Cls
" Lcd "Enter Dev Number
While Z = 16
()Z = Getkbd
Waitms 1000
Wend
(B1 = Lookup(z , Dta
If B1 = 20 Then
Porta = 255
Portb.6 = 1
Goto Sd
End If
D = B1
Cls
Locate 1 , 1
"Lcd " DEVICE
Locate 1 , 7
Lcd D
Waitms 2000
Return
***********************'
Lu: 'lock or unlock
Z = 16
Cls
" Lcd "press lock/unlock Key
While Z = 16
()Z = Getkbd
Waitms 1000
Wend
(B1 = Lookup(z , Dta
B = B1
If B = 24 Then Goto Enterpass 'lock
If B = 25 Then Goto Entercode ' unlock

Return

**************'
:Entercode
%%%%%%%%%%%%%%%%%%%%%%%'
If D = 1 Then
If Porta.0 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 2 Then
If Porta.1 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 3 Then
If Porta.2 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 4 Then
If Porta.3 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If
If D = 5 Then
If Porta.4 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 6 Then
If Porta.5 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 7 Then
If Porta.6 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 8 Then
If Porta.7 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 9 Then
If Portb.6 = 1 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
Cls
"Lcd "Enter Code
Waitms 1000
Cls
For I = 1 To 4
Z = 16
While Z = 16
()Z = Getkbd
Waitms 1000
Wend
(B1 = Lookup(z , Dta
If B1 = 21 Then Goto Entercode
Y(i) = B1
"*" Lcd
Waitms 2000
Next I
Gosub Compare
Return
*******************'
:Enterpass
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'

%%%
If D = 1 Then
If Porta.0 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 2 Then
If Porta.1 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 3 Then
If Porta.2 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 4 Then
If Porta.3 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 5 Then
If Porta.4 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 6 Then
If Porta.5 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 7 Then
If Porta.6 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 8 Then
If Porta.7 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If

If D = 9 Then
If Portb.6 = 0 Then
Cls
"Lcd "error
Waitms 1000
Goto Sd
End If
End If
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
Cls
"Lcd "create Passward
Waitms 1000
Cls
For I = 1 To 4
Z = 16
While Z = 16
()Z = Getkbd
Waitms 1000
Wend
(B1 = Lookup(z , Dta
If B1 = 21 Then Goto Enterpass
If D = 1 Then X(i) = B1
If D = 2 Then E(i) = B1
If D = 3 Then G(i) = B1
If D = 4 Then R(i) = B1
If D = 5 Then S(i) = B1
If D = 6 Then T(i) = B1
If D = 7 Then U(i) = B1
If D = 8 Then V(i) = B1
If D = 9 Then W(i) = B1

"*" Lcd
Waitms 2000
Next I
If D = 1 Then Porta.0 = 0
If D = 2 Then Porta.1 = 0
If D = 3 Then Porta.2 = 0
If D = 4 Then Porta.3 = 0
If D = 5 Then Porta.4 = 0
If D = 6 Then Porta.5 = 0
If D = 7 Then Porta.6 = 0
If D = 8 Then Porta.7 = 0
If D = 9 Then Portb.6 = 0
Return
****************'
:Compare

If D = 1 Then Goto Dev1


If D = 2 Then Goto Dev2
If D = 3 Then Goto Dev3
If D = 4 Then Goto Dev4
If D = 5 Then Goto Dev5
If D = 6 Then Goto Dev6
If D = 7 Then Goto Dev7
If D = 8 Then Goto Dev8
If D = 9 Then Goto Dev9
Return
:Dev1
If Y(1) = X(1) Then
If Y(2) = X(2) Then
If Y(3) = X(3) Then
If Y(4) = X(4) Then
Porta.0 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev2
If Y(1) = E(1) Then
If Y(2) = E(2) Then
If Y(3) = E(3) Then
If Y(4) = E(4) Then
Porta.1 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev3
If Y(1) = G(1) Then
If Y(2) = G(2) Then
If Y(3) = G(3) Then
If Y(4) = G(4) Then
Porta.2 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return

:Dev4
If Y(1) = R(1) Then
If Y(2) = R(2) Then
If Y(3) = R(3) Then
If Y(4) = R(4) Then
Porta.3 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev5
If Y(1) = S(1) Then
If Y(2) = S(2) Then
If Y(3) = S(3) Then
If Y(4) = S(4) Then
Porta.4 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev6
If Y(1) = T(1) Then
If Y(2) = T(2) Then
If Y(3) = T(3) Then
If Y(4) = T(4) Then
Porta.5 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev7
If Y(1) = U(1) Then
If Y(2) = U(2) Then
If Y(3) = U(3) Then
If Y(4) = U(4) Then
Porta.6 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
End If
End If
End If
Return
:Dev8
If Y(1) = V(1) Then
If Y(2) = V(2) Then
If Y(3) = V(3) Then
If Y(4) = V(4) Then
Porta.7 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return
:Dev9
If Y(1) = W(1) Then
If Y(2) = W(2) Then
If Y(3) = W(3) Then
If Y(4) = W(4) Then
Portb.6 = 1
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Else
Cls
"Lcd "ERROR
Portb.7 = 1
Waitms 1000
Portb.7 = 0
End If
Return

:Dta

Data 20 , 21 , 0 , 22 , 23 , 3 , 2 , 1 , 24 , 6 , 5 , 4 , 25 , 9 , 8 , 7

S-ar putea să vă placă și