hello guys
i am working on a project that scans an rfid tag and then displays a certain value if the tags rfid matches with the stored values of rfid. so far i am not successful please tell me what's wrong with my code or suggest me some alternative codes or techniques to do it.
this is the code i am useing
int x=0,y=0;
int count1=0/rfid<----------------------
String cpos[12];
void setup()
{
Serial.begin(9600); // put your setup code here, to run once:
Serial3.begin(9600);
}
void loop()
{
if(Serial3.available())
{ Serial.print("Line AA");
RFread:count1=0;
while(Serial3.available()&& count1<12)
{
cpos[count1]=Serial3.read();
count1++;// put your main code here, to run repeatedly:
delay(5);
}
delay(500);
Serial.println(cpos[12]);
Single quotes are used round single characters. Can you see a problem here ?
There also appear to be some strange characters at the end of the values that you are comparing with. They show up when the code you posted is copied into the IDE
Single quotes are used round single characters. Can you see a problem here ?
There also appear to be some strange characters at the end of the values that you are comparing with. They show up when the code you posted is copied into the IDE
1 - you cannot compare C strings using == you need to use strcmp()
2 - the cpos array is an array of chars, not a C string because you have not added a terminating '\0'
3 - your RFID codes have a very odd trailing character. Copy your code from here back to the IDE to see them. In the IDE they are 13 characters long
4 - the use of the goto command is deprecated and is not necessary. The loop() function does what its name implies, ie it loops, so use that to read the ID characters from Serial