diff --git a/Project Code/doorlock/doorlooc.c b/Project Code/doorlock/doorlooc.c index bb57bd6..6ecf0fc 100644 --- a/Project Code/doorlock/doorlooc.c +++ b/Project Code/doorlock/doorlooc.c @@ -3,6 +3,7 @@ #include // connected pins +sfr LCD_PORT = 0x90; // port 1 >> LCD_PORT // keypad rows sbit keyrow1 = P2 ^ 0; sbit keyrow2 = P2 ^ 1; @@ -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); @@ -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; @@ -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; @@ -96,9 +96,8 @@ void lcddisplay(unsigned char *q) { int k; for (k = 0; q[k] != '\0'; k++) - { lcddat(q[k]); - } + delay(10000); } @@ -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 '#'; } @@ -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 @@ -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 \ No newline at end of file +// end