Hi guys,
I brought the Sparkfun RFID starter kit to play around with,
I managed to get my arduino to read the full ID into a string variable, however when i try and use that string to decided what to display on an LCD things go pear shaped.
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int SerInToArdu=7; //Defines pin data passes
//to Arduino over from RFID reader
const int SerOutFrmArdu=3; //Not used, but
//"fills" a parameter in the set up of
//mySerialPort
String FullCode;
SoftwareSerial mySerialPort(SerInToArdu,SerOutFrmArdu);
// Creates serial port for RFID reader to be attached to.
// Using pins 0 and 1 is problematic, as they are also
// connecting the development PC to the Arduino for
// programming, and for the output sent to the serial
// monitor.
void setup()
{
Serial.begin(9600);//For access to serial monitor channel
Serial.println("Please Scan Card");
lcd.begin(16, 2);
lcd.print("Please Scan Card");
mySerialPort.begin(9600);
delay(1000);
lcd.clear();
};
void loop()
{
int incomingByte=0;//create and initialize a local variable
//The "then" part of the following will only execute
// after the RFID reader has sent something to the Arduino
if (mySerialPort.available() > 0) {
// read the incoming byte from the serial buffer
incomingByte = mySerialPort.read();
// show what was received
//Serial.print(incomingByte, DEC);
//Serial.print(' ');
FullCode = FullCode + " " + incomingByte;
if (incomingByte==3){
Serial.println();
Serial.print("The Full Code is - ");
Serial.print(FullCode);
Serial.println();
if (FullCode == " 2 53 48 48 48 56 70 65 52 66 56 67 51 13 10 3")
{
lcd.print("Your Card Is");
lcd.setCursor(1,2);
lcd.print("67 51");
FullCode = "";
}
if(FullCode != " 2 53 48 48 48 56 70 65 52 66 56 67 51 13 10 3"); //" 2 53 49 48 48 55 66 69 65 52 50 56 50 13 10 3");
{
lcd.print("Your Card Is");
lcd.setCursor(1,2);
lcd.print("56 50");
FullCode = "";
}
delay(4000);
lcd.clear();
FullCode = "";
}
}
}
So instead of displaying that the card is "67 51" or "56 50" (last two numbers as the rest is checksum etc)
the display shows the correct text for card 56 50, but for 67 51 it shows
Your card is
56 50Your Card
Can anyone help?