when reading RFID(MIFARE) information using Arduino mega and display in serial monitor it works fine. But, when printing on 2004LCD only one information(Value) displays correctly. The other information Item Name display a decimal number. Could someone help on this?
void Price(){
block = 4;
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 4, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
status = mfrc522.MIFARE_Read(block, buffer1, &len); // ***Note down buffer1 within the bracket
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failedl: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
//Display price information...
for (uint8_t i = 0; i < 16; i++)
{
if (buffer1[i] != 32) // if buffer1[i] not equal to 32
{
Serial.write(buffer1[i]); //Price
//lcd.write(buffer1[i]);
Value = buffer1[i];
}
}
Serial.print("/=");
Serial.println(" ");
sscanf(buffer1,"%d",&Value);
lcd.setCursor(0,1);
lcd.println(Value);
}
//==========================================================
void Item(){ //----- Get & Display Item information
block = 1;
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 1, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
status = mfrc522.MIFARE_Read(block, buffer2, &len);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
for (uint8_t i = 0; i < 16; i++) { //
Serial.write(buffer2[i]); // Display Item
lcd.write(buffer2[i]);
Item_Name=buffer2[i];
}
sscanf(buffer2,"%s",&Item_Name);
//sprintf(buffer2,"%d",&Item_Name);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Item_Name);// displays numbers instead of "Fresh Milk 1Lt
}
Item_Name
?