Text on LCD differs from Text on Serial Monitor?

This is a snippet of code from the "Example sketch/program showing An Arduino Door Access Control featuring RFID, EEPROM, Relay... ... This is a MFRC522 library example; for further details and other examples see: GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522"

I'm trying to output the Card RfId to the LCD. My hardware and software are configured correctly I can, from within the same program read card Id's and print to the Serial Monitor and I can also print text "Hello World!" to the LCD. However when I try to output the content of readard to the LCD i get gibberish, IE:

  • Serial.println(F("Scanned PICC's UID:"));*
  • for ( uint8_t i = 0; i < 4; i++) { //*
    readCard = mfrc522.uid.uidByte*;*
    _ Serial.print(readCard*, HEX);
    lcd.setCursor(1, 0);
    lcd.print(readCard, HEX);
    }*_

This is a snippet of my answer.

Please remember to use code tags when posting code.

If you are going to post code then please use code tags to prevent it being mangled by some of it being interpreted as HTML commands such as [­i] for italics

Sorry My Bad:

 Serial.println(F("Scanned PICC's UID:"));
 for ( uint8_t i = 0; i < 4; i++) {  //
   readCard[i] = mfrc522.uid.uidByte[i];
   Serial.print(readCard[i], HEX);
   lcd.setCursor(1, 0);
   lcd.print(readCard[i], HEX);
 }

Why do you keep putting the cursor back to 1, 0 ?

Is your "readCard[]" array declares as 'byte' or 'unsigned char'? If it's "char" then any character with the high bit set will get sign-extended to 32 bits. 0x83 will show up as "FFFFFF83".

You re-positioning the LCD cursor for every byte. You are printing all of the bytes on top of each other. Try:

 Serial.println(F("Scanned PICC's UID:"));
 lcd.setCursor(1, 0);
 for ( uint8_t i = 0; i < 4; i++) {  //
   readCard[i] = mfrc522.uid.uidByte[i];
   Serial.print(readCard[i], HEX);
   lcd.print(readCard[i], HEX);
 }

Thanks guys for your interest:

UKHeliBob and johnwasser yep I agree the cursor positioning is bad in my example above I have moved the setCursor to above the for loop and I do get a longer output to the LCD "EwEFuuw" but it's still not what I'm expecting. I'v looked up ASCII table codes and I don't think that's what is coming out on the LCD.

johnwasser cardRead is declared as a byte byte cardRead[4];

This is a snippet of my answer.

Stop posting snippets.

sorry AWOL I'm still learning the forum etiquette so please a little more tolerance, don't tell me waht not to do instead tell me what you'd like me to do..

I'd like you to stop posting snippets of your code.

I assume that you have read this sticky at the top of the forum read this before posting a programming question

AWOL ok I have learned my lesson so now that I've stopped "Snippeting" do you have anything useful to contribute?

UKHeliBob yes i have skimmed the forum posting rules and thought I had actually posted within the expected etiquette. Again I apologize if I'm not.

Hjnr:
AWOL ok I have learned my lesson so now that I've stopped "Snippeting"

I'm not seeing that.

AWOL:
I'm not seeing that.

Well, he/she did not post another snippet.

OP: Post ALL of your code.