I need to compare two different char arrays, however, I've run into a wall. The first array is the RFID tag being swiped and the other is a preset one 0F03029400.
I hope someone can help point me in the right direction and help me realize what im doing wrong. Most of the code is from an arduino tutorial:
// Modified by Worapoht K.
#include <SoftwareSerial.h>
int val = 0;
int ledRed = 3;
char code[10]; // this value is the ID being swiped
int bytesread = 0;
//char admincard[] = "0F03029400";
#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8
void setup()
{
Serial.begin(2400); // Hardware serial for Monitor 2400bps
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2, LOW); // Activate the RFID reader
pinMode(ledRed, OUTPUT);
}
void loop()
{
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
RFID.begin(2400);
if((val = RFID.read()) == 10)
{ // check for header
bytesread = 0;
while(bytesread<10)
{ // read 10 digit code
val = RFID.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
}
//This is where I am having trouble.
if(bytesread == 10)
{ // if 10 digit read is complete
if (code == "0F03029400"){ //"0F03029400"
Serial.println(" CORRECT TAG READ ");
digitalWrite(ledRed, HIGH);
}
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
}
bytesread = 0;
delay(500); // wait for a second
}
delay(1000);
digitalWrite(ledRed, LOW);
}