For the project, we want to import the code for the RFID code in the sketch of the project with cpp and h files, but it gives an error that the mfrc522 has multiple definitions. The first definition can be found in the cpp. Can you help us what to change? Here is the code of the cpp:
#include "Userinterface.h"
Userinterface::Userinterface() {
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
void Userinterface::checkCard() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) return;
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) return;
// Show UID on serial monitor
for (byte i = 0; i < mfrc522.uid.size; i++) {
uid.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
uid.concat(String(mfrc522.uid.uidByte[i], HEX));
}
uid.toUpperCase();
uid = uid.substring(1);
Serial.println(uid);
delay(3000);
}