Skip to content

Update doorlooc.c #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions Project Code/doorlock/doorlooc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <reg51.h>

// connected pins
sfr LCD_PORT = 0x90; // port 1 >> LCD_PORT
// keypad rows
sbit keyrow1 = P2 ^ 0;
sbit keyrow2 = P2 ^ 1;
Expand All @@ -27,21 +28,22 @@ void lcdcmd(unsigned char);
void lcddat(unsigned char);
void lcddisplay(unsigned char *q);
char keypad();
void check();
void delay(unsigned int);
void check(unsigned char *Epin);
void delay(unsigned int j);
unsigned char pin[] = {"12345"};
unsigned char Epin[5];


// main function
void main()
{
unsigned char Epin[5];
lcdcmd(0x0F); //decimal value: 15
lcdcmd(0x38); //decimal value: 56
lcdcmd(0x01); //decimal value: 1

while (1)
{
unsigned int i = 0;
unsigned char i = 0;
lcdcmd(0x80); //decimal value: 128
lcddisplay("ENTER PIN NUMBER");
delay(1000);
Expand All @@ -52,25 +54,23 @@ void main()
delay(1000);
i++;
}
check();
check(Epin);
}
}

//delay function
void delay(unsigned int j)
{
int a, b;
unsigned char b;
int a;
for (a = 0; a < j; a++)
{
for (b = 0; b < 10; b++)
;
}
for (b = 0; b < 10; b++);
}

// lcd commands functions
void lcdcmd(unsigned char A)
{
P1 = A;
LCD_PORT = A;
rs = 0;
rw = 0;
en = 1;
Expand All @@ -82,7 +82,7 @@ void lcdcmd(unsigned char A)

void lcddat(unsigned char i)
{
P1 = i;
LCD_PORT = i;
rs = 1;
rw = 0;
en = 1;
Expand All @@ -96,9 +96,8 @@ void lcddisplay(unsigned char *q)
{
int k;
for (k = 0; q[k] != '\0'; k++)
{
lcddat(q[k]);
}

delay(10000);
}

Expand Down Expand Up @@ -206,14 +205,14 @@ char keypad()
if (keycolumn2 == 0)
{
lcddat('*');
delay(1000);
(1000);
x = 1;
return '0';
}
if (keycolumn3 == 0)
{
lcddat('*');
delay(1000);
(1000);
x = 1;
return '#';
}
Expand All @@ -222,24 +221,24 @@ char keypad()

// password check function and run the door motor

void check()
void check(unsigned char *Epin)
{
// compare the input value with the assign password value
if (pin[0] == Epin[0] && pin[1] == Epin[1] && pin[2] == Epin[2] && pin[3] == Epin[3] && pin[4] == Epin[4])
{
delay(1000);
(1000);
lcdcmd(0x01); //decimal value: 1
lcdcmd(0x81); //decimal value: 129
// show pin is correct
lcddisplay("PIN CORRECT");
delay(1000);
(1000);
// door motor will run
motorpin1 = 1;
motorpin2 = 0;
lcdcmd(0xc1); //decimal value: 193
// show the door is unlocked
lcddisplay("DOOR OPENED");
delay(10000);
(10000);
motorpin1 = 1;
motorpin2 = 0;
lcdcmd(0x01); //decimal value: 1
Expand All @@ -249,9 +248,9 @@ void check()
lcdcmd(0x01); //decimal value: 1
lcdcmd(0x80); //decimal value: 128
lcddisplay("WRONG PIN");
delay(1000);
(1000);
lcdcmd(0x01); //decimal value: 1
}
}

// end
// end