Carnal
Newbie level 3
RFID Project Help
I am doing a project using the parallax 125 Khz RFID reader and I need some help with the code to compare the tag data to the data stored in memory. I am using the PIC18F458 with the CCS compiler. I am using strcmp to compare the two values, but it automatically goes to the else statement I have. Here is what I have for the RFID portion of the project:
I am pretty sure the main function is acting fine because if I just throw a getc() it will do what I want it to. I just do not see why the compare is not working appropriately. Any help would be greatly appreciated.
I am doing a project using the parallax 125 Khz RFID reader and I need some help with the code to compare the tag data to the data stored in memory. I am using the PIC18F458 with the CCS compiler. I am using strcmp to compare the two values, but it automatically goes to the else statement I have. Here is what I have for the RFID portion of the project:
Code:
#include <18F458.h>
#include <stdlib.h>
#fuses NOWDT
#fuses HS
#fuses NOOSCSEN
#fuses BROWNOUT
#fuses BORV27
#fuses NOPUT
#fuses DEBUG
#fuses NOLVP
#use delay (clock=10M)
#use rs232 (baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <stdlib.h>
#include <string.h>
char readin[11]="1100B8E8D1"; //RFID Tag ID
char check[11];
int length, h;
void rx()
{
int i;
length=strlen(readin);
for(i=0;i<length;i++)
{
check[i]=getc();
}
if(strcmp(readin, check) == 0)
{
output_high(PIN_D0);
delay_ms(500);
output_low(PIN_D0);
delay_ms(500);
h=1;
}
else{
output_high(PIN_C3);
delay_ms(500);
output_low(PIN_C3);
delay_ms(500);
h=0;
}
return;
}
void main(void)
{
while(TRUE)
{
while(input(mode)==automatic)
{
if(kbhit())
{
rx();
if(h==1){
auto_up();
delay_ms(5000);
auto_down();
delay_ms(500);
h=0;
}
}
}
}
}
I am pretty sure the main function is acting fine because if I just throw a getc() it will do what I want it to. I just do not see why the compare is not working appropriately. Any help would be greatly appreciated.