numair_noor
Member level 2
hi, i am working on a password based security system . it is a small hobby project,
there are two main things to care of:
1. i am using push buttons for entering the input data. i can not use KEYPAD instead.
2. the way i am coding is not good. but i have to do it like that. though its not efficient. it is so simple code.
exactly what am i doing and what am i looking for help in? PLEASE FIRST HAVE A LOOK AT THIS PART OF CODE.
FOR NOW. THIS PART IS MY CONCERN:
THIS CODE RUNS FINE in software mikroc. but when i put it into proteus.
it does so:
1.waits untill i enter a key from 0 to 9,. and show on screen.(this process repeats three times and shows on lcd which is fine)
2.it has to store the key i had entered above. but i does not show three keys on screen when i ask it to show that array in which it was storing my keystrokes. please help me. its urgent
all other things are working fine till now. i am attaching the picture for understanding easily this project. please help me even if u know a single word about this project.
there are two main things to care of:
1. i am using push buttons for entering the input data. i can not use KEYPAD instead.
2. the way i am coding is not good. but i have to do it like that. though its not efficient. it is so simple code.
exactly what am i doing and what am i looking for help in? PLEASE FIRST HAVE A LOOK AT THIS PART OF CODE.
Code:
//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);
}
FOR NOW. THIS PART IS MY CONCERN:
Code:
[COLOR="#FF8C00"]//here is problem i guess:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,digit);
delay_ms(1000);[/COLOR]
THIS CODE RUNS FINE in software mikroc. but when i put it into proteus.
it does so:
1.waits untill i enter a key from 0 to 9,. and show on screen.(this process repeats three times and shows on lcd which is fine)
2.it has to store the key i had entered above. but i does not show three keys on screen when i ask it to show that array in which it was storing my keystrokes. please help me. its urgent
all other things are working fine till now. i am attaching the picture for understanding easily this project. please help me even if u know a single word about this project.