View previous topic :: View next topic |
Author |
Message |
YarYesreh
Joined: 18 Mar 2009 Posts: 2
|
RFID problem |
Posted: Wed Apr 15, 2009 12:36 pm |
|
|
For a security system I'm working with, implemented with the 18F4520, there is an RFID reader http://www.parallax.com/dl/docs/prod/audiovis/RFID-Reader-v1.1.pdf. I have the RFID reader working but unfortunately I first figured this out in a continuous loop. I would like to just check if and only if the user has tried to scan an RFID card.
Here is what I have code wise so far
Code: | byte code[size]; //For read RFID code
void read_RFID()
{
//printf(lcd_putc,"\fWaiting...\n");
int x;
output_low(PIN_B1);
if(getc() == 0x00)
return;
//while (getc() == 0x00);
for (x = 0; x < size; x++)
{
code[x] = getc();
}
output_high(PIN_B1);
return;
} |
The Commented while statement is what I was first using, and using the if doesn't seem to help any either. I know I probably missing something small but I can't see what.
Any help? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 15, 2009 12:42 pm |
|
|
I'm not completely sure what you want, but I think the kbhit() function
may do it for you. If a character has been received by the UART, then
kbhit() will return 'True'.
The kbhit() function allows you to test and see if a character is available,
before you call getc(). If no character is ready, then don't call getc(). |
|
|
|