I'm having a problem with that code. For some reason, every time the board resets, the first RFID read is a garbage string. I'd paste the output, but apparently that's not possible from the serial monitor.
All other reads are good, until I reset it again. Then, another garbage string before good results.
Is there something I can fix to prevent this, or do I need to code around it?
Still trying to figure this out. Took your idea, Cybernetician, and pulled the array out. Even now though, with resetting the rfidArray repeatedly, it still produces one garbage line prior to reading properly.
I have no idea how to insert an image that isn't hosted onto this site, but I'll work on it (or hosting the image).
Now, though, it seems to be slightly better (with no change to the code - weird). It just adds an extra space to the front of the first read on a reset, but then reads the code just fine.
if(Serial.available())
{
//clearRFID(); No need to execute this funtion two time
int index = 0;
while(Serial.available())
{
rfidArray[index] = Serial.read();
index++;
}
Serial.println(rfidArray);
clearRFID();
}
I was pretty sure that it was a dude with an all lower case name that Grumpy_Mike was posting about in the Website and Forum category, but now I'm not so sure.
Congrats on your output Enjoy
That's half-assed code, at best. Serial.print() expects, when the argument is a char array, for that array to be NULL terminated. That code does NOT NULL terminate the array.
That code does not keep collecting data until the whole packet has arrived. It simply assumes that the whole packet is there, and NOTHING but the packet. Those are both poor assumptions to be making.
I was pretty sure that it was a dude with an all lower case name that Grumpy_Mike was posting about in the Website and Forum category, but now I'm not so sure.