This project is just a smart version of any keypad lock. What’s smart about it is that it can detect whether it is needed by the user or not and accordingly switches itself to take a sleep. Making a microcontroller to sleep reduces power consumption as well as increases its usage span.For this project reader should have knowledge of How to start with AVR and Interface LCD with AVR.
Many of you must be wondering that would it be secure enough to make a lock go to sleep, isn’t it. Don’t worry, when a microcontroller goes off to sleep it puts a hold on what it was doing before sleeping. In my project I have made it to sleep only when the user has finished entering the password stuff and microcontroller has done its entire job.
The Keypad is connected to PORTC and the LCD works on 4-bit mode with PORTB.
Requirements
Circuit Diagram
Project Source Code
###
#include<avr/io.h> #include<util/delay.h> #include<lcd.h> #include<keypad.h> void function() { LCDclr(); LCDGotoXY(0,0); LCDdisplay("ENTER PASSWORD"); LCDGotoXY(1,0); } int i=0,j=0; char k=0,arr[16]="NUL",pass[16]="1234"; void main() { DDRA=1; PORTA=0; LCDinit(); LCDcursorOFF(); while(1) { if(PINA&1) { LCDdisplay("SAFE OPEN"); LCDGotoXY(1,0); } else function(); while(i<15000) { if(!k) i++; else { if(k!='#' && k!='E') { arr[j++]=k; if(PINA&1) LCDsendChar(k); else LCDsendChar('*'); } else if(k=='E' && j!=0) { j--; LCDcursorLeft(1); LCDsendChar(' '); LCDcursorLeft(1); } else if(k!='E') { if(!strcmp(arr,"NUL")) { PORTA=0; LCDclr(); LCDdisplay("SAFE LOCKED"); _delay_ms(1000); function(); } else { arr[j]='