P. 1
Electronic Code Lock With User Defined Password Using 8051 Micro Controller

Electronic Code Lock With User Defined Password Using 8051 Micro Controller

|Views: 1,941|Likes:
Published by Magesh Kumar

More info:

Published by: Magesh Kumar on Mar 01, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

01/14/2013

pdf

text

original

Electronic code lock with user defined password using 8051 microcontroller (AT89C51

)
An electronic lock is a device which has an electronic control assembly attached to it. They are provided with an access control system. This system allows the user to unlock the device with a password. The password is entered by making use of a keypad. The user can also set his password to ensure better protection. The major components include a keypad, LCD and the controller AT89C51 which belongs to the 8051series of microcontrollers. This article describes the making of an electronic code lock using the 8051 microcontroller. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers. 1. Command/Instruction Register- stores the command instructions given to the LCD. A

command is an instruction given to LCD to do a predefined task like initializing, clearing the screen, setting the cursor position, controlling display etc. 2. Data Register- stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

Commonly used LCD Command codes: Hex Code 1 2 4 6 E 80 C0 38 Command to LCD Instruction Register Clear screen display Return home Decrement cursor Increment cursor Display ON, Cursor ON Force the cursor to the beginning of the 1st line Force cursor to the beginning of the 2nd line Use 2 lines and 5x7 matrix

PIN CONFIGURATION: Pin 1 2 3 4 5 6 Symbol VSS VCC VEE RS R/W EN Description Ground Main power supply Power supply to control contrast Register Select Read/write Enable 0V +5 V Contrast adjustment by providing a variable resistor through VCC RS=0 to select Command Register RS=1 to select Data Register R/W=0 to write to the register R/W=1 to read from the register A high to low pulse (minimum 450ns wide) is given when data is sent to data pins 7 8 9 10 11 12 13 14 15 16 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 Led+ Led- To display letters or numbers. Also instruction command codes are sent to these pins. 8-bit data pins Backlight VCC Backlight Ground +5 V 0V . their ASCII codes are sent to data pins (with RS=1).

.

To send data on the LCD. Displaying single character µA¶ on LCD The LCD is interfaced with microcontroller (AT89C51). . it means that LCD is not ready to accept data since it is busy with the internal operations. Here P1 is used as output port which is connected to data pins of the LCD. This program uses the above concepts of interfacing the LCD with controller by displaying the character µA¶ on it. its command register should be read and busy flag should be checked. 2. P1. and P3). To send a command on the LCD. P2. Each write operation is performed on the positive edge of the Enable signal. Pin 3 is connected to a preset of 10k? to adjust the contrast on LCD screen. A high to low pulse is given at EN pin when data is sent.Programming the LCD: 1. The control pins (pin 4-6) are controlled by pins 2-4 of P0 port. When busy flag=1. data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). 3. Therefore before passing any data to LCD. a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent. Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. This microcontroller has 40 pins with four 8-bit ports (P0.

.

e=1.j . void delay(unsigned intmsec) { inti. rw=0.i++) for(j=0. } voidlcdcmd(unsigned char item) { dataport = item. delay(100). rs= 1. sbitrw = cmdport^1. lcddata('A').j++). delay(100). delay(1). sbit e = cmdport^6.j<1275. } voidlcddata(unsigned char item) { dataport = item. delay(100).//Program to test LCD. lcdcmd(0x01). //register select pin // read write pin //enable pin // Function to provide time delay in msec. lcdcmd(0x06). for(i=0.i<msec. delay(100). lcdcmd(0x0E). rw=0. delay(100).h> #define cmdport P3 #define dataport P2 #define q 100 sbitrs = cmdport^0. lcdcmd(0x86). delay(1). e=0. } void main() { lcdcmd(0x38). e=1. } //Function to send command to LCD //Function to send data to LCD // for using 8-bit 2 row mode of LCD // turn display ON for cursor blinking //clear screen //display ON // bring cursor to position 6 of line 1 . e=0. rs= 0. Display single character "A" #include<reg51.

AT89C51 has 4KB of Flash programmable and erasable read only memory (EPROM) and 128 bytes of RAM.. The resistance is varied by adjusting the rotary control over it. It can be erased and program to.. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. LCD: LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. AT89C51 Microcontroller AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ..PRESET: A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The adjustment can be done by using a small screw driver. These modules are preferred over seven segments..

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->