Arca
Published © GPL3+

Arduino RFID Servo Box

This tutorial shows how to make a servo lock.

IntermediateFull instructions provided32,701
Arduino RFID Servo Box

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RFID reader (generic)
Only tested on RC522 RFID Module.
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Servos (Tower Pro MG996R)
×1
Cardboard
×1
A small box for the lock.
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Web Editor
Arduino Web Editor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Only if you want to solder it.

Story

Read more

Schematics

Schematic

Circuit Diagram

Code

Rfid Lock

Arduino
#include <Servo.h>
#include <SPI.h>
#include <RFID.h>

RFID rfid(10, 9);

byte kart[5] = {208,74,76,37,243};
Servo myservo;
boolean card;

void setup()
{

  Serial.begin(9600);
  SPI.begin();
  rfid.init();
  myservo.attach(3);
  myservo.write(100);

}

void loop()
{

  if (rfid.isCard())
  {


    if (rfid.readCardSerial())
    {
      Serial.print("Found ID: ");
      Serial.print(rfid.serNum[0]);
      Serial.print(",");
      Serial.print(rfid.serNum[1]);
      Serial.print(",");
      Serial.print(rfid.serNum[2]);
      Serial.print(",");
      Serial.print(rfid.serNum[3]);
      Serial.print(",");
      Serial.println(rfid.serNum[4]);

    }
    for (int i = 1; i < 5; i++)
    {
      if (rfid.serNum[0] == kart[0] && rfid.serNum[1] == kart[1] && rfid.serNum[2] == kart[2] && rfid.serNum[3] == kart[3] && rfid.serNum[4] == kart[4])
      {
        card = true;
      }
      else {
        card = false;
      }
    }
    if (card == true)
    {
      Serial.println("Correct Card");
      myservo.write(20);
      delay(15000);
      myservo.write(100);
    }
    else
    {
      Serial.println("Wrong Card");

    }
    rfid.halt();
  }
}

RFID Library

Credits

Arca

Arca

1 project • 47 followers

Comments