Introduction: TURN ON LIGHTS WITH RFID CARD
Hi guys! Today we are going make Rfid Card controlled light switch.
When we show first card to reader lights will turn on. When we show second card lights will turn off.
Also you will learn what is the EEPROM.
Let's start..
Watch the video. If you have a problem, you can add a comment..:)
If you like my project please subscribe my YouTube Channel SUBSCRIBE NOW!
Please follow me on Instructables for more useful projects!.:)
Step 1: What Will We Use?
- Arduino
- RFID Module
- Relay Module
- Breadboard
Step 2: Connections;
RC522 to Arduino;
3.3v to 3.3v
RST to D9
GND TO GND
IRQ TO (NONE)
MISO TO D12
MOSI TO D11
SCK TO D13
SDA TO D10
Relay To Arduino;
Gnd to Gnd
Vcc to 5v
Signal to D7
Step 3: EEPROM Using;
You will see 2 different code in data. What should you do?
- Firstly you should upload the ''rfid_setup'' code,
- Open the serial monitor
- You have to show 2 different idcards in 2 different times
- If you done this work, you can upload the second code to your Arduino
- Finally you can use your device.
Step 4: Code Download Link:
You can download the arduino code from this link;
>>> Download Now! <<<
If you didn't read the last step please read!
Step 5: Test;
Please watch the video.
If you like my project please subscribe my YouTube ChannelSUBSCRIBE NOW!
Please follow me on Instructables for more useful projects!.:)

Participated in the
Invention Challenge 2017

Participated in the
Power Supply Contest
8 Comments
4 years ago
i tried everything but it is not working with my relay i have an
5v Relay Module for Arduino ARM PIC AVR MCU 5V Indicator Light LED 1 Channel Relay Module please helpReply 2 years ago
the relay is not in the code
Question 5 years ago on Step 2
Hello, I am Trying to use this code for my dissertation. I get the first code to notice my card and fob and I receive 2 ID numbers for these. But when it tells me to upload the working code it say's exit status 1
'kart1' was not declared in this scope
and shows an error
Please could you help
Answer 2 years ago
here is the working code:
/****************************************************************
* THIS PROJECT BELONG TO ENSAR LEVENT.
* YOU CAN GET OTHER PROJECTS FROM INSTRUCTABLES
* https://www.instructables.com/member/ensarlevent/...
Tested with SparkFun Arduino Nano
****************************************************************/
#include
#include
#include
const int buttonPin = 7;
int buttonState = 0;
#define RST_PIN 9
#define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
String lastRfid = "";
String card1 = "";
String card2 = "";
MFRC522::MIFARE_Key key;
void setup()
{
pinMode(buttonPin, INPUT);
buttonState = digitalRead(buttonPin);
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("RFID Card Reader");
Serial.println("--------------------------");
Serial.println();
readEEPROM();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
String rfid = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
rfid += mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ";
rfid += String(mfrc522.uid.uidByte[i], HEX);
}
rfid.trim();
rfid.toUpperCase();
if (rfid == lastRfid)
return;
lastRfid = rfid;
Serial.print("Card 1: ");
Serial.println(card1);
Serial.print("Card 2: ");
Serial.println(card2);
Serial.print("Now: ");
Serial.println(rfid);
Serial.println();
if (rfid == card1)
{
Serial.println("Turned On.");
delay (2000);
}
if (rfid == card2)
{
Serial.println("Turned Off");
delay (2000);
}
Serial.println();
delay(200);
}
void readEEPROM()
{
for (int i = 0 ; i < 4 ; i++)
{
card1 += EEPROM.read(i) < 0x10 ? " 0" : " ";
card1 += String(EEPROM.read(i), HEX);
}
for (int i = 4 ; i < 8 ; i++)
{
card2 += EEPROM.read(i) < 0x10 ? " 0" : " ";
card2 += String(EEPROM.read(i), HEX);
}
card1.trim();
card1.toUpperCase();
card2.trim();
card2.toUpperCase();
}
Answer 5 years ago
Where you find It has (kart1) and (kart2) just change the code .
Change ...
Serial.println(kart1);
Serial.println(kart2);
To ...
Serial.println(card1);
Serial.println(card2);
Question 4 years ago on Step 5
How did you connected that led to the relay ?
Answer 4 years ago
Please my relay is not turning on when i put the card on the receiver
Question 4 years ago
it is not working with my relay please help