//numair password is 782
unsigned int f,digit[3]={0,0,0},nreg[3]={7,8,2};
unsigned char i=0,j=0;
void reg();
void Lcd_Init();
// Lcd module connections
sbit LCD_RS at P2_0_bit;
sbit LCD_EN at P2_1_bit;
sbit LCD_D4 at P2_2_bit;
sbit LCD_D5 at P2_3_bit;
sbit LCD_D6 at P2_4_bit;
sbit LCD_D7 at P2_5_bit;
// End Lcd module connections
void main() {
p1=0x00;
p3=0x00;
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
LCD_OUT(1,1,"ENTER REG. #");
while(1)
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
LCD_OUT(1,1,"ENTER REG. #");
////////push buttons FUNCTIONS START////////////////
reg();//ENTER REGISTERATION NUMBER
}
}
void reg() //function for registeration number
{
for(i=0;i<3;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); //wait for any key to be pressed
if(p1.b0==1)
{
digit[i]='0'; //put 0 in digit[i]
Lcd_Out(2,i+1,"0"); //LCD OUT =0
while(p1.b0!=0);
}
else if(p1.b1==1)
{
digit[i]='1'; //put 1 in digit[i]
LCD_OUT(2,i+1,"1"); //LCD OUT =1
while(p1.b1!=0);
}
else if(p1.b2==1)
{
digit[i]='2'; //put 2 in digit[i]
LCD_OUT(2,i+1,"2"); //LCD OUT =2
while(p1.b2!=0);
}
else if(p1.b3==1)
{
digit[i]='3'; //put 3 in digit[i]
LCD_OUT(2,i+1,"3");//LCD OUT =3
while(p1.b3!=0);
}
else if(p1.b4==1)
{
digit[i]='4'; //put 4 in digit[i]
LCD_OUT(2,i+1,"4");//LCD OUT =4
while(p1.b4!=0);
}
else if(p1.b5==1)
{
digit[i]='5';//put 5 in digit[i]
LCD_OUT(2,i+1,"5");//LCD OUT =5
while(p1.b5!=0);
}
else if(p1.b6==1)
{
digit[i]='6'; //put 6 in digit[i]
LCD_OUT(2,i+1,"6");//LCD OUT =6
while(p1.b6!=0);
}
else if(p1.b7==1)
{
digit[i]='7'; //put 7 in digit[i]
LCD_OUT(2,i+1,"7");//LCD OUT =7
while(p1.b7!=0);
}
else if(p3.b0==1)
{
digit[i]='8'; //put 8 in digit[i]
LCD_OUT(2,i+1,"8");//LCD OUT =8
while(p3.b0!=0);
}
else if(p3.b1==1)
{
digit[i]='9'; //put 9 in digit[i]
LCD_OUT(2,i+1,"9");//LCD OUT =9
while(p3.b1!=0);
}
}
//here is problem i guess:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,digit);
delay_ms(1000);
}