Pages

Wednesday 18 January 2012

Sunday 24 July 2011

Digital clock with code lock & temperature sensor using PIC16F877A


INTRODUCTION

Digital code lock can be used for security purposes on doors , cupboards , desks etc. Once installed it works without any maintenance and no need to keep key always with yourself. It also shows time,day and current room temperature on its home screen which is sensed using LM35 temperature sensor.
Microcontroller keeps scanning the keypad , when * is pressed it allows code to be entered and “enter code ” on lcd is displayed , now the 4 digit code can be entered to open the door. The default code has been set as 4619 . when correct code is entered the lcd displays “welcome” and led glows for 3 seconds otherwise “wrong code” is displayed on screen and then lcd goes back to home screen. If someone presses * to enter mode and leaves it there then the microcontroller waits for an input for 7 seconds then it goes back to home screen if no key is pressed. Same happens if incomplete code is entered and is left.
Time and day can be set at start up with the help of keypad.
The temperature and time displayed on the screen is refreshed every 54 seconds.

COMPONENTS

Micro-controller (Pic16f877a or any others with around 20 i/o pins)
16x2 LCD
4x3 KEYPAD
LM35 temperature sensor
and a crystal oscillator,strip board,some wires,capacitors and resistors.

CONNECTIONS

LCD is connected to Port B of pic 16f877a, pins 7,8,9,10 of lcd should be left floating as only pins 11,12,13,14 are used to send data, pin 5 of the lcd should be grounded as data has to written on lcd, pin 3 is used to set contrast of lcd, it can be connected to 5k potentiometer or directly to Vss.
Rows of keypad are connected to port D and are grounded via 100k resistors while columns of keypad are connected to port C via 10k resistors.
Temperature sensor LM35 output pin is connected to AN1.
A push button switch is provided between MCLR and ground to reset the microcontroller.
A led is connected to RA2 which glows when correct password is entered via keypad.
A 4MHz crystal oscillator is suitable for this kind of application as precise and stable frequency is needed and at 4MHz power consumed is also not high.

 SCHEMATICS
 HEX FILE