i need to know how to save user input in array using at89c51/52, i am using mikroc software for 8051.
this is my code so far:
please help me urgent
this is my code so far:
please help me urgent
Rich (BB code):
//numair registeration # is 782
//saeed registeration # is 287
//numair password is 456
//saeed passwords is 123
//char nreg[3]={'7','8','2'};
//char ncreg[3];
//int strcmp(char *s1,char *s2);
///unsigned int npass[3]={4,5,6};
///unsigned int ch[3];
unsigned int f,digit[3]={0,0,0},nreg[3]={7,8,2};
unsigned char i=0,j=0;
void reg();
void pass();
void check();
void Lcd_Init();
//void display(char p,char v);
// 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; //PORT 1 is at sink
//P3=0x00; //PORT 3 is at sink
//S:
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
//check();
}
}
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)
{
//f=0;
digit=0; //put 0 in digit
Lcd_Out(2,i+1,"0"); //LCD OUT =0
while(p1.b0!=0);
}
else if(p1.b1==1)
{
//f=1;
digit=1; //put 1 in digit
LCD_OUT(2,i+1,"1"); //LCD OUT =1
while(p1.b1!=0);
//f=0;
}
else if(p1.b2==1)
{
//f=2;
digit=2; //put 2 in digit
LCD_OUT(2,i+1,"2"); //LCD OUT =2
while(p1.b2!=0);
//f=0;
//ncreg=2;
}
else if(p1.b3==1)
{
//f=3;
digit=3; //put 3 in digit
LCD_OUT(2,i+1,"3");//LCD OUT =3
while(p1.b3!=0);
//f=0;
}
else if(p1.b4==1)
{
//f=4;
digit=4; //put 4 in digit
LCD_OUT(2,i+1,"4");//LCD OUT =4
while(p1.b4!=0);
///f=0;
}
else if(p1.b5==1)
{
//f=5;
digit=5;//put 5 in digit
LCD_OUT(2,i+1,"5");//LCD OUT =5
while(p1.b5!=0);
//f=0;
}
else if(p1.b6==1)
{
//f=6;
digit=6; //put 6 in digit
LCD_OUT(2,i+1,"6");//LCD OUT =6
while(p1.b6!=0);
//f=0;
}
else if(p1.b7==1)
{
//f=7;
digit=7; //put 7 in digit
LCD_OUT(2,i+1,"7");//LCD OUT =7
while(p1.b7!=0);
}
else if(p3.b0==1)
{
//f=8;
digit=8; //put 8 in digit
LCD_OUT(2,i+1,"8");//LCD OUT =8
while(p3.b0!=0);
//f=0;
//ncreg=8;
}
else if(p3.b1==1)
{
//f=9;
digit=9; //put 9 in digit
LCD_OUT(2,i+1,"9");//LCD OUT =9
while(p3.b1!=0);
//f=0;
}
// else if(p3.b2==1)
// {
//f=10;
//='*';
// LCD_OUT(2,i+1,"*");//LCD OUT = * (10 for *)
// while(p3.b2!=0);
//f=0;
// }
// else if(p3.b3==1)
{
//f=20;
//ar='#';
// LCD_OUT(2,i+1,"#"); //LCD OUT = #
// while(p3.b3!=0);
//f=0;
// }
}
//now here is problem i guess:( please help... please please
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,digit[]);
delay_ms(1000);
//for(j=0;j<3;j++)
//{ // if(nreg.toString[] == comp.toString[])
//if(nreg[j]=ar[j])// && (nreg[3]==comp[3]))// && //(nreg[2]==comp[3]))
//{
// Lcd_Cmd(_LCD_CLEAR);
//Lcd_Out(1,j,'ar[j]');
//delay_ms(1000);
//}
//else
//{
//Lcd_Out(1,2,digit[2]);
//delay_ms(1000);
//Lcd_Out(1,3,digit[3]);
// delay_ms(1000);
//}
}
} //}