Project tutorial
Arduino RFID Servo Box

Arduino RFID Servo Box © GPL3+

This tutorial shows how to make a servo lock.

  • 612 views
  • 3 comments
  • 4 respects

Components and supplies

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

Necessary tools and machines

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

Apps and online services

About this project

Let me tell you something:

Having a lock is a useful thing. And if it's made out of Arduino, then that's an even better thing. Let's get started.

Step 1: Building the lock

First I glued a cardboard strip on the lid of the box so when I put the lid back on

it was the bit in the box where the servo would hold. Then, I stuck the servo motor so that when it was at 90° angle, it would hold the cardboard and stop the box opening.

And it ended up like this:

Step 2: The circuit diagram

So the next step is connecting the Arduino. Connect the Arduino like this:

Step 3: Fix the Arduino on the box

I used sticky tape to fix the Arduino on the box.

Step 4: Upload the code

Don'tforgettoaddtheRFIDLibrarytotheArduinoIDE (you can find the library at the code bit of this tutorial).

Copy the code and paste it to your Arduino IDE and upload it.

Step 5: Done!

Then...you're done! If you have a question, I can answer it.

Code

Rfid LockArduino
#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();
  }
}

Schematics

Schematic
Lock iw4vigkmzv
Circuit Diagram
lock_YlE65x0V02.fzz

Comments

Similar projects you might like

Arduino Controlled Lock Box with Solenoid and RFID

Project tutorial by RobotGeek Projects Team

  • 5,806 views
  • 3 comments
  • 20 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 7,716 views
  • 5 comments
  • 23 respects

Bluetooth Controlled Servo

Project tutorial by JANAK13

  • 2,724 views
  • 9 comments
  • 18 respects

rfid attendance system using arduino with GSM

Project tutorial by sarful

  • 9,267 views
  • 3 comments
  • 17 respects

Arduino RFID Lock Tutorial

Project tutorial by Nick Koumaris

  • 8,642 views
  • 2 comments
  • 26 respects
Add projectSign up / Login