Hi, i modified the code and it works.
But when i press the button it not 'stable'.....for an example, there are two id tagged and when i press once it will show the data for the first id. Then when press second time it suppose will show second data of the second id, but i need to press many time only the second data will appear in the lcd.
How to fix the problem?
Thanks.
Here is the code that i modified.
- CODE: SELECT_ALL_CODE
unsigned char uart_rec(void) //receive uart value
{
unsigned char rec_data;
while(RCIF==0) //wait for data
{
if (button1==0&&present[0]==0)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("Not Present!"); //display "Not Present "
lcd_goto(20); //set lcd cursor to location 20
for(i=0;i<10;i+=1)send_char(user_1[i]); //display user name
delay(100);
}
if (button1==0&&present[1]==0)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("Not Present!"); //display "Not Present "
lcd_goto(20); //set lcd cursor to location 20
for(i=0;i<10;i+=1)send_char(user_2[i]); //display user name
delay(100);
}
if (button1==0&&present[2]==0)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("Not Present!"); //display "Not Present "
lcd_goto(20); //set lcd cursor to location 20
for(i=0;i<10;i+=1)send_char(user_3[i]); //display user name
delay(100);
}
if (button1==0&&present[0]==1&&present[1]==1&&present[2]==1)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("All Present!"); //display "Alll Present "
delay(100);
}
if (button2==0&&present[0]==1)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("ID: "); //display "ID: "
for(i=0;i<10;i+=1)send_char(id_1[i]); //display tag ID
lcd_goto(20); //set lcd cursor to location 20
send_string("user: "); //display "user: "
for(i=0;i<10;i+=1)send_char(user_1[i]); //display user name
entry+=1;
delay(100);
}
if (button2==0&&present[1]==1)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("ID: "); //display "ID: "
for(i=0;i<10;i+=1)send_char(id_2[i]); //display tag ID
lcd_goto(20); //set lcd cursor to location 20
send_string("user: "); //display "user: "
for(i=0;i<10;i+=1)send_char(user_2[i]); //display user name
entry+=1;
delay(100);
}
if (button2==0&&present[2]==1)
{
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("ID: "); //display "ID: "
for(i=0;i<10;i+=1)send_char(id_3[i]); //display tag ID
lcd_goto(20); //set lcd cursor to location 20
send_string("user: "); //display "user: "
for(i=0;i<10;i+=1)send_char(user_3[i]); //display user name
entry+=1;
delay(100);
}
}
rec_data = RCREG;
return rec_data; //return the data received
}