I have already spent many hours with the Arduino (Uno) and the program for the RFID sensor (RFID-RC522). However, I have not found a suitable code on the Internet that meets my requirements. I have found a code that is conditionally good but still does not do what I would like (https://www.viralsciencecreativity.com/post/arduino-rfid-sensor-mfrc522-tutorial). I would like to have the following functions: if a chip is recognized, which is not stored in the program, that the digital output 3 is controlled. If chip 1 or 2 is recognized, the output 4 should be controlled. If chip 3 or 4 is recognized, output 5 is to be controlled. If chip 5 or 6 is detected, output 6 should be activated.
The outputs should be activated for about 2 seconds. Where I still have a problem would be the chip two, because it has not four digits, but seven.
In the linked code a beeper is programmed in, I don't need it for example and it is also only possible to store a card that has only one function.
I would be very grateful if someone would take the trouble to help me.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
what does it mean if you write "the digital output 3 is controlled" ????
This is an unprecise description. You should clearly describe in detail what shall happen.
Your own effort that you have shown to your potential helpers so far is:
Having searched on the internet for a suitable code (unprecise description no number "I have searched "X" hours for a code that meets my requirements"
A link to a website where one code that seems to do do half what you want
What do you think:....... did you already show great own effort??? No you didn't.
The willingness to help you will increase dramatically, if you can prove and testify to your own commitment.
You can attest your own effort by actually doing the work you can do yourself.
This work that you can do is:
The most important step to do this is to post a sketch as a code-section.
asking any - and if I write "any" I really mean any question that is specific about the code you want to use as the starting point.
posting the exact type of RFID-reader you have
posting a datasheet of your RFID-reader
writing, if you have successfully managed to compile and upload a working demo-code that simply reads the card and prints the cardnumber to the serial monitor.
Or in case it did not work writing a detailed description of the steps you made and what you observed.
Even if you have any question about any step of how to work with Arduino just ask this question.
Even if you have a question about the very first line of the code just ask this specific question.
Nobody here will write down another RFID-code-tutorial that especially meets your requirement and will cover all and any possible question that you might have.
You have to ask your specific questions.
Specific questions are much much easier to answer because they are specific.
You should post your own attempt how you assume how a modification of the code might be done.
You wrote about removing the buzzer.
Post the original code from the link as a code-section
then modify this code by commenting out these lines of code that you assume could be removed
commenting out is done by starting the line with double-slash "//"
So simply add double-dashes on the left to these lines of code where you assume this code can be removed because it only has to do with the buzzer.
And then post the modified code as a second code-section.
Here you can read how you can post code as a code-section:
looks like the code in the link you posted recognizes a single RFID tag and you want to be able to recognize several different tags and momentarily (?) turn on specific outputs
create a "struct" composed of RFID tags and LED pins that can be searched when an RFID tag is found and turn on the corresponding LED
@ruilviana
Hello,
thanks for your effort, unfortunately the RFID reader does not recognize any chip (I added all six chips) unfortunately none of them go. The next problem is that the serial monitor does not work (I could do without it). My last question is if I can just add the code 77 5I 9C I9 3E 96 60 or if I have to change something in the code because it is longer than the others.
With kind regards Erik
Hi,
I'm sorry, but I made some mistakes in typing the tag index.
I set up your project here *without turning on LEDS, but using printout), and tested it.
My last two tags have a different format, but they served for the test.
Here is the result and the corrected code.
//Viral Science
//RFID
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define LED_Y 3 //define green LED pin
#define LED_W 4 //define red LED
#define LED_G 5 //define green LED pin
#define LED_R 6 //define red LED
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
//String stored[6] = {"83 23 38 BB", "84 23 38 BB", "85 23 38 BB", "86 23 38 BB", "87 23 38 BB", "88 23 38 BB"};
String stored[6] = {"FE CD 0F BB", "E6 3D 0E BB", "46 F8 1F 7E", "26 9E 1A 7E", "EB A0 F8 E3", "37 92 0E FB" };
//----------------------------------------------------------------------
void lowLEDS()
{
digitalWrite(LED_Y, LOW);
digitalWrite(LED_W, LOW);
digitalWrite(LED_G, LOW);
digitalWrite(LED_R, LOW);
}
//----------------------------------------------------------------------
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
pinMode(LED_Y, OUTPUT);
pinMode(LED_W, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
lowLEDS();
Serial.println("Put your card to the reader...");
Serial.println();
}
//----------------------------------------------------------------------
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
lowLEDS();
return;
//lowLEDS();
}
// 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) == stored[0] or content.substring(1) == stored[1]) //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println("turn on W");
Serial.println();
delay(500);
digitalWrite(LED_W, HIGH);
return;
}
if (content.substring(1) == stored[2] or content.substring(1) == stored[3]) //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println("turn on G");
Serial.println();
delay(500);
digitalWrite(LED_G, HIGH);
return;
}
if (content.substring(1) == stored[4] or content.substring(1) == stored[5]) //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println("turn on R");
Serial.println();
delay(500);
digitalWrite(LED_R, HIGH);
return;
}
Serial.println("Authorized access");
Serial.println("turn on Y");
Serial.println();
delay(500);
digitalWrite(LED_Y, HIGH);
return;
}
UID tag : FE CD 0F BB
Message : Authorized access
turn on W
UID tag : E6 3D 0E BB
Message : Authorized access
turn on W
UID tag : 26 9E 1A 7E
Message : Authorized access
turn on G
UID tag : 46 F8 1F 7E
Message : Authorized access
turn on G
UID tag : EB A0 F8 E3
Message : Authorized access
turn on R
UID tag : 37 92 0E FB
Message : Authorized access
turn on R
UID tag : 04 AE 96 9A 43 29 80
Message : Authorized access
turn on Y
UID tag : 04 B6 C0 8A 43 29 80
Message : Authorized access
turn on Y
@ruilviana
Hi,
thank you very much for your help, that's exactly how I imagined it. If I can return the favor in any way just write. Now I can finally finish my project. I find it amazing that there are so nice people like you, who make the effort for others to write a code as desired, I can only thank you again that you help a 16-year-old boy interested in electronics.
Your favor would be to learn to understand how the code works even after receiving the working code.
Without understanding the code you finish your project unknowing.
Do you have to present the project?
Do you have to answer questions like
"what do you have to change in the code if another RFID-card shall be added to the code?
"what must be changed in the code if a special presenting-"gesture" must be done
like hold card to the reader a first LEDs is switched on remove card wait 10 seconds present card again and only then switch on the other LED?
[Solved] @StefanL38
Hello Stefan,
I am currently very busy with studying for school because I am graduating this year. That's why I don't have time to integrate programming into my everyday life. The project is not for school, but for me privately, because I experiment and tinker with technology in my little free time. The project is for an access control for a technical room where each chip has different permissions. The outputs of the Arduino will be inserted in a freely programmable controller (Siemens SPS), through which I can assign other functions.