0% found this document useful (0 votes)
13 views4 pages

Password Lock Door12

The document defines pins for an LCD display and initializes a keypad. It gets a password from the keypad by calling a get_number function, which displays the numbers on the LCD and returns a character array. It checks the password and runs a motor if the password is correct.

Uploaded by

Montaha Alduais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Password Lock Door12

The document defines pins for an LCD display and initializes a keypad. It gets a password from the keypad by calling a get_number function, which displays the numbers on the LCD and returns a character array. It checks the password and runs a motor if the password is correct.

Uploaded by

Montaha Alduais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

sbit LCD_RS at RD2_bit;

sbit LCD_EN at RD3_bit;

sbit LCD_D4 at RD4_bit;

sbit LCD_D5 at RD5_bit;

sbit LCD_D6 at RD6_bit;

sbit LCD_D7 at RD7_bit;

// Pin direction

sbit LCD_RS_Direction at TRISD2_bit;

sbit LCD_EN_Direction at TRISD3_bit;

sbit LCD_D4_Direction at TRISD4_bit;

sbit LCD_D5_Direction at TRISD5_bit;

sbit LCD_D6_Direction at TRISD6_bit;

sbit LCD_D7_Direction at TRISD7_bit;

char keypadPort at PORTB ;


int array[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

char array2[10]={'0','1','2','3','4','5','6','7','8','9'};

char no[16];

int no1[16];

char n=0;

int i;

char x;

char get_number(){

Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1,1, "password?");

for(i=0;i<16;i++){no[i]=0;

for(i=0;i<16;i++){

while(no[i]==0){

no[i]=Keypad_Key_Click();

if(no[i]==1){ no[i]='7'; no1[i]=7;}

if(no[i]==2) {no[i]='8'; no1[i]=8;}

if(no[i]==3) {no[i]='9'; no1[i]=9;}

if(no[i]==5) {no[i]='4';no1[i]=4;}

if(no[i]==6) {no[i]='5';no1[i]=5;}

if(no[i]==7) {no[i]='6';no1[i]=6; }

if(no[i]==9) {no[i]='1';no1[i]=1; }

if(no[i]==10) {no[i]='2';no1[i]=2; }

if(no[i]==11) {no[i]='3';no1[i]=3; }

if(no[i]==14) {no[i]='0';no1[i]=0; }

if(no[i]==16) {no[i]='.';no1[i]=0; }

if(no[i]==1234) {no[i]="correct" ; }
if(no[i]==15){

return 0;}

Lcd_chr(2,i+1,no[i]);

void main() {

TRISD = 0xFF; //PORTD as input

TRISC = 0x00; //PORTC as output

TRISA = 0x00; //PORTB as output

//Run motor in anticlock wise

Keypad_Init();

Lcd_Init();

while(1){

get_number();

if(no[0]=='1' && no[1]=='2'&& no[2]=='3'){

PORTA = 0x02;

PWM1_Init(5000);

PWM1_Start();

PWM1_Set_Duty(255);

delay_ms(500);

PWM1_Stop();

}
}

You might also like