Welcome to this site, next time use ctrl-k to align your code.
The problem is in:
Serial.print(mfrc522.uid.uidByte{i} < 0x10 ? " 0" : " ");
To get the value of an array, use [i]
, not {i}
, thus
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
(similar to other lines).
To give some additional hints:
Try to prevent duplicated code by storing the byte into a variable. Now you can use uidValue
in the subsequent lines.
uint8_t uidValue = mfrc522.uid.uidByte[i];
Store 0x10 inside a constant.
So you get:
const uint8_t MAX_HEX_SINGLE_DIGIT_VALUE 0x0F;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
uint8_t uid_byte = mfrc522.uid.uidByte[i];
Serial.print(uid_byte < LOW_VALUE <= MAX_HEX_SINGLE_DIGIT_VALUE ? " 0" : " ");
Serial.print(uid_byte, HEX);
content.concat(String(uid_byte < MAX_HEX_SINGLE_DIGIT_VALUE ? " 0" : " "));
content.concat(String((uid_byte, HEX));
}
I assume the Serial lines are only for debugging, otherwise you can combine them too.
[
,]
) instead of curly brackets. Replace all instances of{i}
with[i]
and you will be good to go.