hi guys,
I am still pretty new to Arduino so please bear with me. I am working with and RFID tag to scan a card. I got code working and the tag works fine, but only on one computer, not on my laptop(Mac) or another Dell. The origanal computer, where the code works is a Mac and it has a different operating system compared to my laptop.
I have downloaded all the libraries that are nessary, and the version of Arduino is the same.
Here is my code.
Any help would be really appericated.
/* Start of Code */
/* Simple RFID Arduino Sketch(RC522)
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
The MFRC522 Library used, was created by LJOS here: GitHub - ljos/MFRC522: Arduino RFID Library for MFRC522
The FastLED Library used, was created by focalintent here: Releases · FastLED/FastLED · GitHub
*/
#include <MFRC522.h> // Include of the RC522 Library
#include <SPI.h> // Used for communication via SPI with the Module
#define SDAPIN 10 // RFID Module SDA Pin is connected to the UNO 10 Pin
#define RESETPIN 8 // RFID Module RST Pin is connected to the UNO 8 Pin
byte FoundTag; // Variable used to check if Tag was found
byte ReadTag; // Variable used to store anti-collision value to read Tag information
byte TagData[MAX_LEN]; // Variable used to store Full Tag Data
byte TagSerialNumber[5]; // Variable used to store only Tag Serial Number
byte GoodTagSerialNumber[5] = {12, 134, 158, 211}; // The Tag Serial number we are looking for
byte GoodTagSerialNumber2[5] = {192, 252, 71, 37}; // The Tag Serial number we are looking for
MFRC522 nfc(SDAPIN, RESETPIN); // Init of the library using the UNO pins declared above
void setup() {
SPI.begin();
Serial.begin(115200);
// Start to find an RFID Module
Serial.println("Looking for RFID Reader");
nfc.begin();
byte version = nfc.getFirmwareVersion(); // Variable to store Firmware version of the Module
// If can't find an RFID Module
if (! version) {
Serial.print("Didn't find RC522 board.");
while(1); //Wait until a RFID Module is found
}
// If found, print the information about the RFID Module
Serial.print("Found chip RC522 ");
Serial.print("Firmware version: 0x");
Serial.println(version, HEX);
Serial.println();
}
void loop() {
String GoodTag="False"; // Variable used to confirm good Tag Detected
// Check to see if a Tag was detected
// If yes, then the variable FoundTag will contain "MI_OK"
FoundTag = nfc.requestTag(MF1_REQIDL, TagData);
if (FoundTag == MI_OK) {
delay(200);
// Get anti-collision value to properly read information from the Tag
ReadTag = nfc.antiCollision(TagData);
memcpy(TagSerialNumber, TagData, 4); // Write the Tag information in the TagSerialNumber variable
//Serial.println("Tag detected.");
//Serial.print("Serial Number: ");
for (int i = 0; i < 4; i++) { // Loop to print serial number to serial monitor
Serial.print(TagSerialNumber*);*
Serial.print(", ");
}
Serial.println("");
Serial.println();
// Check if detected Tag has the right Serial number we are looking for
for(int i=0; i < 4; i++){
if (GoodTagSerialNumber != TagSerialNumber*) {*
break; // if not equal, then break out of the "for" loop
}
if (i == 3) { // if we made it to 4 loops then the Tag Serial numbers are matching
GoodTag="TRUE";
}
}
if (GoodTag == "TRUE"){
Serial.println("Success!!!!!!!");
Serial.println();
}
//check another card
// Check if detected Tag has the right Serial number we are looking for
for(int i=0; i < 4; i++){
if (GoodTagSerialNumber2 != TagSerialNumber*) {*
break; // if not equal, then break out of the "for" loop
}
if (i == 3) { // if we made it to 4 loops then the Tag Serial numbers are matching
GoodTag="TRUE";
}
}
if (GoodTag == "TRUE"){
Serial.println("Another Success!!!!!!!");
Serial.println();
}
}
}
////end of code//