Hi!
I have an issue with my code for my RFID project. I'm trying to get input from the serial console that is longer than one character. Help?
Code:
if (option == 'w') {
while (Serial.available() == 0) {
String stringVariable( Serial.readString() );
strcpy(stringBuffer, stringVariable); // you may try a different string here, with LESS than MAX_STRING_SIZE characters
int stringSize = strlen(stringBuffer);
// starting from tag's block #1, writes a data chunk labeled "mylabel", with its content given by stringBuffer, of stringSize+1 bytes (because of the trailing 0 in strings)
result = rfidReader.writeFile(BLOCK, "mylabel", (byte*)stringBuffer, stringSize+1);
if (result >= 0) {
printfSerial("--> Successfully written \"%s\" to the tag, ending in block %d\n", stringBuffer, result);
} else {
printfSerial("--> Error writing to the tag: %d\n", result);
}
}
}
-eetnaviation