8 pins on RC522 module.
You plug the cord into these 7 pins.
Then connect to the Arduino according to the diagram above.
Step 3: Connect Relay Module with Arduino
Relay module works to help us control devices with large voltages such as 220V, if directly controlled with devices running 220V, the Arduino circuit will be damaged.
The Replay module will have 6 pins, DC + DC - is the 2nd pin supplying small voltage from Arduino output, IN is the input signal pin.
COM and NC NO are pins for us to use to switch off electrical devices. COM is the middle foot. NC stands for Normal Close which means normally closed. NO is Normal Open meaning normally open.
You connect DC + wires to 5V pins, DC wires - to GND pins, IN wires to pin 2.
On the other side of the Relay, you connect 1 wire of the power to the COM port. The remaining power cord is connected to the light bulb. The other end of the light bulb is connected to the N0 pin.
So we are done connecting. Now we will proceed to load the code.
Step 4: Load the code to get the ID of the card
Since Arduino does not have the MFRC522 library available, we need to add it to Arduino. You download the MFRC522 library here.
After downloading the library, click on Sketch then select Include Library and select Add . Zip Library .
A new window will appear. Select the library file you just downloaded and then click Open. The library will be added to Arduino.
After adding the library, copy this code into Arduino on your computer.
#include
#include
const int LED1 = 2;
const int LED2 = 2;
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522 (SS_PIN, RST_PIN);
unsigned long uidDec, uidDecTemp;
byte bCounter, readBit;
unsigned long ticketNumber;
void setup () {
pinMode (LED1, OUTPUT);
pinMode (LED2, OUTPUT);
Serial.begin (9600);
SPI.begin ();
mfrc522.PCD_Init ();
Serial.println ("GenK Arduino / Hay quits the ID test .");
}
void loop () {
if (! mfrc522.PICC_IsNewCardPresent ()) {
return;
}
if (! mfrc522.PICC_ReadCardSerial ()) {
return;
}
uidDec = 0;
Serial.println ("********************************************* *** ");
Serial.println ("ID of the la:");
for (byte i = 0; i
uidDecTemp = mfrc522.uid.uidByte [i];
uidDec = uidDec * 256 uidDecTemp;
}
Serial.print ("[");
Serial.print (uidDec);
if (uidDec == 3828924583) {
digitalWrite (LED1,! digitalRead (LED1));
delay (1000);
} else {
}
// --------------------------------
if (uidDec == 1506337237) {
digitalWrite (LED2,! digitalRead (LED2));
delay (1000);
} else {
}
Serial.println ("]");
Serial.println ("........ . ");
}
Press V to translate the code.
Click on the arrow icon to load the code.
After successfully loading the code, press Ctrl Shift M to open the Serial Monitor port on the screen.
ID of the card after scanning.
If you swipe the card via the RC522 ID card, it will display on the screen. When buying RC522 module, you will be given a PET plastic card and a key tag.
Step 5: Fill in your card ID into CODE
Replace your card ID here.
After having the ID of the card then you change this ID into 2 lines with the arrow above and proceed to reload the code into Arduino.
Swipe with PET plastic card.
So we're done.
You can put it into your wallet.
With a PET card, you can put it into your wallet like this.
Insert a PET card into your wallet.
The card still works normally when inserted into the wallet.
Swipe with a tag.
With the tag you can hook into the key, very convenient.
Good luck!