So I can view the string but can not use the string with any operators like match string and use it:
while(rfid.available()>0)
{
c=rfid.read();
msg += c;
Serial.println(msg);
Serial.println(msg.length());
}
if(msg.length()>=10) // this number is low to get the correct string size to print... any bigger the string has extra bits
{
digitalWrite (RedLED,LOW); //Test for now to see if string came in, always works! //rfid.println(msg);
if(msg == "BDECF6F696569696965695E5EB00" || msg == "BDECF6F6965616B6F5DD95E5EB00") // either card does not work! but if i make it <= that works... but not what I need!
{
rfid.println(msg);
//digitalWrite (GreenLED,LOW);
msg="";
}
else {rfid.println(msg);msg="";} // the will print out the serial port the in coming string and I will receive: [BD][EC][F6][F6][96][56][96][96][96][56][95][E5][EB][00] and looks correct 90% of the time???
};
I have also tried the longer code with memcmp operator and that would not even print back what was stored as a byte or print out "code" as a long enuff string to match the card number...
I suspect that you are including some framing character in your string. The Parallax reader I have sends ten decimal digits followed by CR and LF (0x13 and 0x10).
// PARALLAX RFID VCC to Arduino 5V
// PARALLAX RFID /ENABLE to Arduino D2
// PARALLAX RFID SOUT to Arduino D3
// PARALLAX RFID GND to Arduino Gnd
// Modified by Worapoht K.
#include <SoftwareSerial.h>
#define enablePin 2
#define rxPin 3
#define txPin 4
SoftwareSerial RFID = SoftwareSerial(rxPin, txPin);
#define START_CHAR 10
#define END_CHAR 13
void setup()
{
Serial.begin(9600); // Hardware serial for Monitor 2400bps
RFID.begin(2400); // RFID reader SOUT at 2400bps
pinMode(enablePin,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(enablePin, LOW); // Activate the RFID reader
}
void loop()
{
int bytesread, val;
String code = "";
digitalWrite(enablePin, LOW); // Activate the RFID reader
// Wait for header byte
while(RFID.read() != START_CHAR)
/* DO NOTHING */ ;
bytesread = 0;
while ((val = RFID.read()) != END_CHAR)
{
if (val == START_CHAR)
break; // Bad frame
bytesread++;
if (bytesread > 10)
break; // Too many characters
code += val; // append the character
}
digitalWrite(enablePin, HIGH); // Deactivate the RFID reader
if (bytesread == 10) // Valid read. 10 characters + END_CHAR
{ // if 10 digit read is complete
if (code == "48524953696548555648")
Serial.println("That's the round tag.");
else
if (code == "48704851485249505067")
Serial.println("That's the rectangular tag.");
else
{
Serial.print("Unrecognized code: "); // possibly a good TAG
Serial.println(code); // print the TAG code
}
}
delay(1000); // wait for a second
}