Hi there,
I’m trying to compare an Array element with String in my Arduino Uno project for the past 5-6 hours and I got an error message every time saying “cannot convert ‘String’ to ‘const char’”*
My code:
#include <SoftwareSerial.h>
SoftwareSerial RFID(2, 3);
int i;
String rfid_in = "";
char read_chr;
char* authTags[4][4];
void initauthTags() {
authTags[0][0] = "22004C22FFB3";
authTags[0][1] = "22004CD971C6";
authTags[0][2] = "22004C317728";
authTags[0][3] = "22004C0F4627";
authTags[1][0] = "John";
authTags[1][1] = "George";
authTags[1][2] = "Peter";
authTags[1][3] = "Josh";
}
void setup(){
RFID.begin(9600);
Serial.begin(9600);
initauthTags();
}
void loop(){
while(RFID.available() > 0){
read_chr = RFID.read();
rfid_in += read_chr;
}
for (i = 0; i < 4; ++i) {
if (strcmp(authTags[0][i], rfid_in.c_str()) == 0) {
Serial.println(authTags[1][i]); // Sends the Username to the Serial port
}else{
Serial.println("DENIDED");
}
}
}
I getting that error on IF statement line in the LOOP sequence, but I can’t figure out because I don’t know quite good this language.
Please help me to solve this issue for me!