'Storing RFID UID's to output in serial monitor when a switch is pressed
I am trying to store 4 UID's to be printed once a switch is turned on, the only way that I see to do this is with array's. But I am still pretty new to this language and I am pretty lost on how to go about it. Any help would be much appreciated, please feel free to ask Questions if you have any and I shall do my best to answer them
This is what I have for my code so far
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
pinMode(4,OUTPUT);
pinMode(3,OUTPUT);
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();
}
void loop() {
// 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) == "43 F0 DC 31") //to find card uid go to the serial moniter, scan your card and copy uid into the section
{
Serial.println("*** has entered");
Serial.println();
delay(3000);
return;
}
if (content.substring(1) == "B1 F6 5B 19") //to find card uid go to the serial moniter, scan your card and copy uid into the section
{
Serial.println("*** has entered");
Serial.println();
delay(3000);
}
if (content.substring(1) == "63 3C 3F 31") //to find card uid go to the serial moniter, scan your card and copy uid into the section
{
Serial.println(" **** has entered");
Serial.println();
delay(3000);
}
}
Any Help would be much appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
