numair_noor
Member level 2
hi, i need some one's help in my code. my code does this:
1:it ask for entering user name:
if user name is correct e.g nasir,basit,imran etc
2.it ask's for entering password
otherwise go back to entering username
PROBLEM:
1.it is not entering into the ''entering password'' screen.
2.i dont konw if it is comparing the user names or not.
code:
- - - Updated - - -
this is the schematic for above code: this is 8052 based project written in c language in mikroc software.
1:it ask for entering user name:
if user name is correct e.g nasir,basit,imran etc
2.it ask's for entering password
otherwise go back to entering username
PROBLEM:
1.it is not entering into the ''entering password'' screen.
2.i dont konw if it is comparing the user names or not.
code:
Code:
bit pass_flag;
bit bb,nn,ii;
char kp[3];
char basit[5]={'b','a','s','i','t'},nasir[5]={'n','a','s','i','r'},imran[5]={'i','m','r','a','n'};//saeed[5]={'s','a','e','e','d'};
char basit_pass[5]={'1','2','3','4','5'},nasir_pass[5]={'2','3','4','5','6'},imran_pass[5]={'3','4','5','6','7'};
//const char nreg[], nreg[];
unsigned char x,y,f,i=0,j=0;
void LCD_SHOW(char x,char y);
void name();
void Lcd_Init();
void dis_ent_pass();
void lcd_welcome();
// Lcd module connections
sbit LCD_RS at P0_0_bit;
sbit LCD_EN at P0_1_bit;
sbit LCD_D4 at P0_2_bit;
sbit LCD_D5 at P0_3_bit;
sbit LCD_D6 at P0_4_bit;
sbit LCD_D7 at P0_5_bit;
// End Lcd module connections
///////start lcd function
LCD_SHOW(char x,char y)
{
if(pass_flag==0)
{
Lcd_chr(2,x+1,y);}
else if(pass_flag==1)
{
Lcd_out(2,x+1,"*");
}
//return(x,y);
}
///end lcd function
void main()
{
//again:
p1=0x00;
p2=0x00;
p3=0x00;
Lcd_Init();
while(1)
{
////////push buttons FUNCTIONS START////////////////
pass_flag=0;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
LCD_OUT(1,1,"enter name");
if(pass_flag==0)
{
name();//enter name
}
else if(pass_flag==1)
{
name(); //enter password if password flag is 1
}
pass_flag=0;
}
}
void name() //function for registeration number
{
for(i=0;i<5;i++)
{
while( (p1.b0!=1) && (p1.b1!=1) && (p1.b2!=1) && (p1.b3!=1) && (p1.b4!=1) && (p1.b5!=1) && (p1.b6!=1) && (p1.b7!=1) && (p3.b0!=1) && (p3.b1!=1) && (p3.b2!=1) && (p3.b3!=1) && (p3.b4!=1) && (p3.b5!=1) && (p3.b6!=1) && (p3.b7!=1) && (p2.b0!=1) && (p2.b1!=1) && (p2.b2!=1) && (p2.b3!=1) && (p2.b4!=1) && (p2.b5!=1) && (p2.b6!=1) && (p2.b7!=1) ); //wait for any key to be pressed
//////////////////new start/////////////////
if(p2.b0==1) //for a
{
f='a';
kp[i]='a';
LCD_SHOW(i,f);
while(p2.b0!=0);
}
else if(p2.b1==1) //for b
{
f='b';
kp[i]='b';
LCD_SHOW(i,f);
while(p2.b1!=0);
}
else if(p2.b2==1) //for d
{
f='d';
kp[i]='d';
LCD_SHOW(i,f);
while(p2.b2!=0);
}
else if(p2.b3==1) //for l
{
f='e';
kp[i]='e';
LCD_SHOW(i,f);
while(p2.b3!=0);
}
else if(p2.b4==1) //for m
{
f='i';
kp[i]='i';
LCD_SHOW(i,f);
while(p2.b4!=0);
}
else if(p2.b5==1) //for m
{
f='m';
kp[i]='m';
LCD_SHOW(i,f);
while(p2.b5!=0);
}
else if(p2.b6==1) ///for n
{
f='n';
kp[i]='n';
LCD_SHOW(i,f);
while(p2.b6!=0);
}
else if(p2.b7==1) //////for r
{
f='r';
kp[i]='r';
LCD_SHOW(i,f);
while(p2.b7!=0);
}
else if(p3.b7==1) ////for s
{
f='s';
kp[i]='s';
LCD_SHOW(i,f);
while(p3.b7!=0);
}
else if(p3.b6==1) ////for t
{
f='t';
kp[i]='t';
LCD_SHOW(i,f);
while(p3.b6!=0);
}
else if(p1.b0==1) ////for 0
{
f='0';
kp[i]='0';
LCD_SHOW(i,f);
while(p1.b0!=0);
}
else if(p1.b1==1) //for 1
{
f='1';
kp[i]='1';
LCD_SHOW(i,f);
while(p1.b1!=0);
}
else if(p1.b2==1) //for 2
{
f='2';
kp[i]='2';
LCD_SHOW(i,f);
while(p1.b2!=0);
}
else if(p1.b3==1) //for 3
{
f='3';
kp[i]='3';
LCD_SHOW(i,f);
while(p1.b3!=0);
}
else if(p1.b4==1) //for 4
{
f='4';
kp[i]='4';
LCD_SHOW(i,f);
while(p1.b4!=0);
}
else if(p1.b5==1) //for 5
{
f='5';
kp[i]='5';
LCD_SHOW(i,f);
while(p1.b5!=0);
}
else if(p1.b6==1) ///for 6
{
f='6';
kp[i]='6';
LCD_SHOW(i,f);
while(p1.b6!=0);
}
else if(p1.b7==1) //for 7
{
f='7';
kp[i]='7';
LCD_SHOW(i,f);
while(p1.b7!=0);
}
else if(p3.b0==1) //for 8
{
f='8';
kp[i]='8';
LCD_SHOW(i,f);
while(p3.b0!=0);
}
else if(p3.b1==1) //for 9
{
f='9';
kp[i]='9';
LCD_SHOW(i,f);
while(p3.b1!=0);
}
else if(p3.b2==1) //////////for *
{
f='*';
kp[i]='*';
LCD_SHOW(i,f);
while(p3.b0!=0);
}
else if(p3.b3==1) /////for #
{
f='#';
kp[i]='#';
LCD_SHOW(i,f);
while(p3.b3!=0);
}
/////////////////////name end before comparison/////////////
}
if( (kp[0]==nasir[0]) && ( kp[1]==nasir[1]) && ( kp[2]==nasir[2]) && ( kp[3]==nasir[3]) && (kp[4]==nasir[4]) && (pass_flag==0))
{
nn=1;
dis_ent_pass();
}
else if( (kp[0]==basit[0]) && ( kp[1]==basit[1]) && ( kp[2]==basit[2]) && ( kp[3]==basit[3]) && (kp[4]==basit[4])&& (pass_flag==0))
{
bb=1;
dis_ent_pass();
}
else if( (kp[0]==imran[0]) && ( kp[1]==imran[1]) && ( kp[2]==imran[2]) && ( kp[3]==imran[3]) && ( kp[4]==imran[4])&& (pass_flag==0))
{
ii=1;
dis_ent_pass();
}
else
{
LCD_OUT(1,1,"enter name");
}
// else if(pass_flag==1)
// {
if((kp[0]==nasir_pass[0]) && ( kp[1]==nasir_pass[1]) && ( kp[2]==nasir_pass[2]) && ( kp[3]==nasir_pass[3]) && ( kp[4]==nasir_pass[4]) && (nn==1))
{
lcd_welcome();
}
else if((kp[0]==basit_pass[0]) && ( kp[1]==basit_pass[1]) && ( kp[2]==basit_pass[2]) && ( kp[3]==basit_pass[3]) && ( kp[4]==basit_pass[4]) && (bb==1))
{
lcd_welcome();
}
else if ( (kp[0]==imran_pass[0]) && ( kp[1]==imran_pass[1]) && ( kp[2]==imran_pass[2]) && ( kp[3]==imran_pass[3]) && ( kp[4]==imran_pass[4]) && (ii==1) )
{
lcd_welcome();
}
//}
}
void dis_ent_pass()
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"ENTER PASSWORD");
pass_flag==1;
}
void lcd_welcome()
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,4,"WELCOME");
pass_flag=0;
nn=ii=bb=0;
}
- - - Updated - - -
this is the schematic for above code: this is 8052 based project written in c language in mikroc software.