RFid checking tag number against tag number list

This is my feeble attempt to combine code I have found online. This is my second day of playing with my arduino with no C programming expierience. I want to check the scanned RFid tag number against a list of numbers that the system will grant access. I am getting the following error. invalid types ‘char* [2] [char*]’ for array subscript
Any help would be welcome Thanks in advance

// Parallax-RFID-LCDShiftReg-0.0.2 RFID reader for Arduino with LCD output
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan> 
// Modified for Arudino by djmatic
// And pieces from Arduino Playground <http://www.arduino.cc/playground/Learning/PRFID>
// And then modified again by thekidd <http://www.tekcrack.com/category/rfid>
// 25.04.2008 - Added modified LCD4×40Bit-ShiftReg connection to display RFID results.
//              Fixed attachInterrupt lockup problem. Was set to CHANGE mode. Now set to LOW mode.
// 12.04.2008 - Added interrupt to ensure program does not hang on RFID reader.

#include <avr/interrupt.h>
#include <SoftwareSerial.h>


#define rxPin 2
#define txPin 3
#define ledPin 13
char*tags[]=
{"0f03041975","0f03041976"};

// LCD Variables

// RFID Variables
int  val = 0; 
int bytesread = 0;
char code[10];
int flag = 0;
int granted = 0;
int i;


// set up a soft serial port
SoftwareSerial mySerial(rxPin, txPin); 

void setup() { 
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);    // Set rxPin as INPUT to accept SOUT from RFID pin
  pinMode(txPin, OUTPUT);   // Set txPin as OUTPUT to connect it to the RFID /ENABLE pin
  pinMode(ledPin, OUTPUT);
Serial.begin(9600);  // Let the user know whats up

  // set the data rate for the serial ports
  mySerial.begin(2400);
delay(100);  // RFID reader SOUT pin connected to Serial RX pin at 2400bps
defaultMsg();

 

  

  attachInterrupt(0, readRFID, LOW); // Setup interrupt for SOUT on RFID reader
  digitalWrite(txPin, LOW);           // Activate the RFID reader
} 

void loop() { 
  // Do Something
for (i=0;i<2;i++)
  goRFID();  
} 

void goRFID() {
  if (flag == 1) { 
    delay(1000);
    Serial.println("Welcome to DCA");
    Serial.println("Tag code is");
    Serial.println(code);
    
             // print the TAG code
    validateRFID(code);             // Determine if right tag used. */
    flag = 0; 
    delay(5000);
    digitalWrite(txPin, LOW);
defaultMsg();    // Activate the RFID reader
    
  } else {
    delay(1000);
    digitalWrite(txPin, LOW);
    defaultMsg();// Activate the RFID reader
    
  }
}
    

void readRFID() {
  digitalWrite(ledPin, LOW);          // Turn off debug LED - Event triggered!
  if((val = mySerial.read()) == 10) { // check for header 
    bytesread = 0; 

    while(bytesread<10) {             // read 10 digit code 
      val = mySerial.read(); 

      if((val == 10)||(val == 13)) {  // if header or stop bytes before the 10 digit reading 
        break;                        // stop reading 
      } 

      code[bytesread] = val;          // add the digit           
      bytesread++;                    // ready to read next digit  
    } 

    if(bytesread == 10) {             // If 10 digit read is complete 
      digitalWrite(txPin, HIGH);      // deactivate RFID reader 
      digitalWrite(ledPin, HIGH);     // activate LED to show an RFID card was read
      flag = 1;
    } 

    bytesread = 0; 
  }
}

void validateRFID (char*i){
  if( strncmp(tags[i],code, 10) == 0) {
     
    digitalWrite(ledPin, HIGH);
    Serial.println("Tag Matches...Access Granted.");
  delay(3000);  
   
    digitalWrite(ledPin, LOW); 
  } else {

    
    digitalWrite(ledPin, LOW);
  }
}
void defaultMsg(){
  Serial.println("Welcome to DCA");
  Serial.println("Please swipe card");
}
if( strncmp(tags[i], code, 10) == 0) {

Looks like “i” is supposed to be a loop index, not a string.

void validateRFID (){
 for (int i = 0; i < sizeof (tags) / sizeof (tags [0]); ++i) {
   if( strncmp(tags[i],code, 10) == 0) {
    
      digitalWrite(ledPin, HIGH);
      Serial.println("Tag Matches...Access Granted.");
      delay(3000);  
  
      digitalWrite(ledPin, LOW);
    } else {

    
      digitalWrite(ledPin, LOW);
    }
  }
}

and

             // print the TAG code
    validateRFID();             // Determine if right tag used. */

In the validateRFID function, i is declared to be a pointer to char. Then, you are (trying to) use it as though it was an int.

The tags variable is an array of “pointer to char” objects.

I think that you are trying to compare the input “pointer to char” to the items in the array (list) of “pointer to char”.

That would make validateRFID look something like this:

#define validTagCnt 2
void validateRFID(char *pTag)
{
    for(int i=0; i<validTagCnt; i++)
   {
       if(strncmp(tags[i], pTag, 10) == 0)
       {
           // Tag is valid
           break;
       }
       else
       {
           // Tag isn't this one
       }
    } // end of tag checking loop
}

It would be even better if validateRFID was declared

bool validateRFID(char *pTag)

and returned a valur of true or false, depending on whether the tag was valid, or not.

I have tried both ideas to no avail. I am not really sure if I have placed the code in the right spot. The error codes actually got worse. Thanks for the suggestions.

Why don't you post your code, and the problem(s) you're having. We'll help you understand what needs to be done.

The error codes actually got worse

The solution I quoted compiles without error, but since I don't have your hardware, I can't check it actually works. The only real differene between mine and PaulS's solution is mine uses "code" as a global, rather than as a reference.

The code in question is in my first post. I am assuming that it shows up when some one looks at the post. The idea behind the code is to allow someone with an authorized rfid card to gain access to a room. LEDpin 13 will light simulating a solenoid releasing a door lock. The code should check authorized codes "0f03041975" and deny access to codes that are not in the program. Thanks again for your help.

If you make the changes I posted in reply #1, the program will compile. As to whether or not it will work, as I said, I don't have your hardware, so that I can't help you with.

Thank you for the suggestions. I did find the problem in the code. Some how I had text inside the () after the word void validateFRID that had nothing to do with the program. I also found a space between void validateRFID and the (). I am not sure if that would have any effect but I removed it. Again, thank you all for your time and help.