Today, I am going to share a similar project in which I have simulated an Electronic Door lock using PIC Microcontroller. I have used PIC18F452 Microcontroller and the compiler I have used for designing the code in MikroC Pro For PIC and the simulation is designed in Proteus ISIS. The code and the Proteus simulation are given for download below. You can also design this project using Arduino or any other microcontroller like 8051 Microcontroller. Let's start with this project.
Note:
I have divided this Electronic Door Locks Project into few parts, and I have explained them separately. You can download the complete project along with the Proteus simulation by clicking the below button. But as I always suggest don't just download it, also design it on your own so that you learn more from it:
Electronic Door Locks using PIC Microcontroller char Indata;
char P1 = '1';
char P2 = '2';
char P3 = '3';
int PassCheck = 0;
int WrongCheck = 0;
int CPassCheck = 0;
void Initialization()
{
UART1_Init(9600);
TRISD = 0;
PortD = 0;
P1 = EEPROM_Read(0x01);
P2 = EEPROM_Read(0x02);
P3 = EEPROM_Read(0x03);
}
void PassChange()
{
while(1)
{
if (UART1_Data_Ready())
{
Indata = UART1_Read();
if(CPassCheck == 2){
CPassCheck = 3;
EEPROM_Write(0x03, Indata);
P3 = EEPROM_Read(0x03);}
if(CPassCheck == 1){
CPassCheck = 2;
EEPROM_Write(0x02, Indata);
P2 = EEPROM_Read(0x02);}
if(CPassCheck == 0){
CPassCheck = 1;
EEPROM_Write(0x01, Indata);
P1 = EEPROM_Read(0x01);}
UART1_Write_Text("*");
if(CPassCheck == 3){break;}
}
}
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13);
}
void CorrectPass()
{
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("Select one of the below Options: ");
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("1) Press Y to Lock.");
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("2) Press N to Unlock.");
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("3) Press C to Change Password.");
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("Waiting for Response: ");
while(1)
{
if (UART1_Data_Ready())
{
Indata = UART1_Read();
if((Indata == 'Y') || (Indata == 'y')){
UART1_Write_Text("Y");
PortD.F0 = 1;
PortD.F1 = 0;
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13); break;}
if((Indata == 'N') || (Indata == 'n')){
UART1_Write_Text("N");
PortD.F0 = 0;
PortD.F1 = 1;
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13); break;}
if((Indata == 'C') || (Indata == 'c')){
UART1_Write_Text("C");
UART1_Write(10);
UART1_Write(13);
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("Enter New Password: ");
PassChange();break;}
}
}
}
void WrongPass()
{
int x = 0;
PortD.F5 = 1;
while(1)
{
PortD.F2 = 1;
Delay_ms(100);
PortD.F2 = 0;
PortD.F3 = 1;
Delay_ms(100);
PortD.F3 = 0;
PortD.F4 = 1;
Delay_ms(100);
PortD.F4 = 0;
x = x + 1;
if(x > 30){break;}
}
PortD.F5 = 0;
}
void main() {
Initialization();
do
{
UART1_Write_Text("Enter Password: ");
while(1)
{
if (UART1_Data_Ready())
{
Indata = UART1_Read();
if((Indata == P1) && (PassCheck == 0)){PassCheck = 1;}
if((Indata == P2) && (PassCheck == 1)){PassCheck = 2;}
if((Indata == P3) && (PassCheck == 2)){PassCheck = 3;}
if((Indata == 13) && (PassCheck == 3)){
PassCheck = 0;
WrongCheck = 0;
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("Correct Password.");
CorrectPass();break;}
if((Indata == 13) && (PassCheck != 3)){
PassCheck = 0;
UART1_Write(10);
UART1_Write(13);
UART1_Write_Text("Wrong Password.");
WrongCheck = WrongCheck + 1;
if(WrongCheck == 3){WrongPass();}
UART1_Write(10); UART1_Write(13);
UART1_Write(10); UART1_Write(13);break;}
UART1_Write_Text("*");
}
}
} while(1);
}
That's all for the electronic smart door lock project using PIC Microcontroller. I hope you have enjoyed it. Will meet you guys in the next tutorial soon. Till then take care and have fun. :)
All these projects are completely designed by our team so other bloggers are welcome to share them on their blogs to share the knowledge but do mention our blog link as a favor. Moreover, if you guys got into any trouble in any of these tutorials then ask in comments and I will try my best to resolve them as fast as I could. I will keep on updating this list. Whenever I post some new electronics project on my blog, I will share the link here. So, its like we are having all electronics projects in one place. I hope you are gonna like it. I have divided these electronics projects in sections depecding upon the microcontroller used for designing them. I have used Arduino , PIC Microcontroller and 8051 Microcontroller usually for designing electronics projects so I have divided it in the same category. Let's get started with it:
I have divided these projects in separate sections as posting them all at once will make them a mess. So, I have divided them according to their types and I think it will be easy to read them out that way. So, first of there's Arduino based Electronics Proejcts and after that I have posted electronics projects on PIC Microcontroller and finally on 8051 Microcontroller. I have also added few projects on 555 Timer at the end. So, let's start with it:
So, that's all for today. I hope you are gonna enjoy these Electronics Projects. Actually I am compiling things on my blog and giving them a proper arrangement. :) If you have any suggestion please post in the comments. So, take care and have fun !!! :)