I am creating a toolbox that can log the tools taken from the toolbox.
Im using an RFID reader and an SD card reader at the same time.
it seems like i have a problem between the two components.
if anyone has a clue about it please tell
the part of the code that gives error
//rfid reader #include <SPI.h> #include <MFRC522.h>
//værktøjs værdier
const int ledSvendsknolge = 8;
const int ledUmbraco = 7;
const int ledKoben = 6;
int switchStatus = 0;
int wait = 2000;
int svendsknolgePa=1;
int svendsknolgeAf=0;
int umbracoPa=1;
int umbracoAf=0;
int kobenPa=1;
int kobenAf=0;
void setup() {
//setup til rfid reader
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
delay(4);
Serial.println("Approximate your card to the reader...");
Serial.println();
//setup til værktøj af og på
pinMode(ledSvendsknolge, INPUT);
pinMode(ledUmbraco, INPUT);
pinMode(ledKoben, INPUT);
//setup for SD kort
Serial.print("Initializing SD card...");
if(!SD.begin(CS_SD)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
// loop for rfid reader
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "2C 8D F0 37" or content.substring(1) == "9E BD 1D C2") //change here the UID of the card/cards that you want to give access
{
Serial.println("velkommen");
delay(300);
}
else {
Serial.println(" Access denied");
delay(300);
}
if (content.substring(1) == "2C 8D F0 37")
{
Serial.println("Test person");
delay(300);
}
if (content.substring(1) == "9E BD 1D C2")
{
Serial.println("Anders Mark Sorensen");
delay(300);
}
//loop for værktøj
{
Serial.print(vogn);
Serial.println("");
Serial.print("----------------");
Serial.println("");