To compare the rfid code with known codes.

Hello,
I need a program where i could compare the code from rfid reader to a set of known codes and then produce an output correspondingly. Since i’m new to programming i don’t know the correct keywords to be used in the program. Anyhow, i have prepared a code for the comparison. I’m posting it here.
The values stored in the char arrays are noted down from the serial monitor after reading the tags.
But the code shows errors stating invalid conversion from char to const void* :confused:
Any help will be appreciated. :slight_smile:
int len=0;
char rtag[12];
char act1[12]={‘0’,‘8’,‘0’,‘0’,‘8’,‘8’,‘3’,‘1’,‘8’,‘6’,‘3’,‘7’};
char act2[12]={‘0’,‘8’,‘0’,‘0’,‘8’,‘8’,‘2’,‘7’,‘D’,‘8’,‘7’,‘F’};
char act3[12]={‘4’,‘3’,‘0’,‘0’,‘7’,‘7’,‘9’,‘1’,‘2’,‘9’,‘8’,‘C’};
void setup()
{
Serial.begin(9600);
}

void loop()
{
int tag1=12;
len=0;
while(Serial.available() && len<12)
{
rtag[len]=Serial.read();
if(memcmp(rtag,act1[len],tag1)==0)
{
Serial.print(“Shelf 1”);
}
else
if(memcmp(rtag,act2[len],tag1)==0)
{
Serial.print(“Shelf 2”);
}
else
if(memcmp(rtag,act3[len],tag1)==0)
{
Serial.print(“Shelf 3”);
}
len++;
delay(5);
}
}

It would be easy to Serial.print rtag and act1[len] so you see what you are comparing with memcmp.
I have never seen memcmp before, but to me it looks like you are comparing an array (rtag) with an element in another array (act1[len]).

Don't you want to wait until you've got a whole tag's worth of characters before doing the compares?

Please remember to use code tags when posting code.

int len=0;
char rtag[12];
char act1[12]={‘0’,‘8’,‘0’,‘0’,‘8’,‘8’,‘3’,‘1’,‘8’,‘6’,‘3’,‘7’};
char act2[12]={‘0’,‘8’,‘0’,‘0’,‘8’,‘8’,‘2’,‘7’,‘D’,‘8’,‘7’,‘F’};
char act3[12]={‘4’,‘3’,‘0’,‘0’,‘7’,‘7’,‘9’,‘1’,‘2’,‘9’,‘8’,‘C’};
void setup()
{
Serial.begin(9600);
}

void loop()
{
int tag1=12;
len=0;
while(Serial.available() && len<12)
{
rtag[len]=Serial.read();
len++;
delay(1000);
}
Serial.print(rtag);
for(len=0; len<=12; len++)
{
if(memcmp(rtag[len],act1[len],tag1)==0)
{
Serial.print(“Shelf 1”);
}
else
if(memcmp(rtag[len],act2[len],tag1)==0)
{
Serial.print(“Shelf 2”);
}
else
if(memcmp(rtag[len],act3[len],tag1)==0)
{
Serial.print(“Shelf 3”);
}
len++;
delay(5);
}
}

Still the same error. Invalid conversion from char to const void*(-fpermissive). Does anyone know what is this error about?

Please see reply #2

following are the code tags:
080088318637
08008827D87F
43007791298C

for(len=0; len<=12; len++)You’ve only got three tags to compare against, so why are you doing this thirteen times?

len represents the length of the array. it corresponds to all the 12 elements of the code which we need to compare one by one. Thats where i have doubt, what is the correct way to compare?

if(memcmp(rtag,act1,tag1)==0)etc

len represents the length of the array. it corresponds to all the 12 elements of the code

The question is moot now, but why thirteen times?

to compare each letter of the code, the code has 12 numbers right?

Correct.
Or, as you have it “tag1” numbers (characters)

So, whats wrong with the program?
Any help will be appreciated. :slight_smile:

Did you read reply #8?

How are your reader connected? Only one serial port defined, and I assume it is your computer as serial.print is used.
Here they use software serial to connect rfid reader to pin 2 and 3. In that way rfid reader can be connected while serial monitor is used for output.

rfid reader is connected to arduino's rx pin. Yeah i want to see output through the serial monitor.