Circuit:
Download Programming:
#include <Servo.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <SPI.h>
// Create instances
LiquidCrystal_I2C lcd(0x27,16,2);
MFRC522 mfrc522(10, 9); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo1;
char initial_password[4] = {'0', '8', '0', '6'}; // Variable to store initial password
String tagUID = "43 19 8A 1A"; // String to store UID of tag. Change it with your tag's UID
char password[4]; // Variable to store users password
boolean RFIDMode = true; // boolean to change modes
char key_pressed = 0; // Variable to store incoming keys
uint8_t i = 0; // Variable used for counter
const int buzzer= 5;
const int motor= 7;
// defining how many rows and columns our keypad have
const byte rows = 4;
const byte columns = 4;
int val = 0;
int myval = 0;
// Keypad pin map
char hexaKeys[rows][columns] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
// Initializing pins for keypad
byte row_pins[rows] = {A0, A1, A2, A3};
byte column_pins[columns] = {2, 1, 0};
// Create instance for keypad
Keypad keypad_key = Keypad( makeKeymap(hexaKeys), row_pins, column_pins, rows, columns);
void setup() {
  lcd.init(); // initialize the lcd
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  SPI.begin(); // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522
  pinMode(buzzer, OUTPUT);
  pinMode(motor, OUTPUT);
  myservo1.attach(3);
 Â
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("-----ATM------");
  lcd.setCursor(0, 1);
  lcd.print("BeyonD Payment's");
 Â
  delay(5000);
}
void loop() {
  // System will first look for mode
  if (RFIDMode == true) {
;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Tap Your Card!");
    // Look for new cards
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
      return;
    }
    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial()) {
      return;
    }
    //Reading from the card
    String tag = "";
    for (byte j = 0; j < mfrc522.uid.size; j++)
    {
      tag.concat(String(mfrc522.uid.uidByte[j] < 0x10 ? " 0" : " "));
      tag.concat(String(mfrc522.uid.uidByte[j], HEX));
    }
    tag.toUpperCase();
    //Checking the card
    if (tag.substring(1) == tagUID)
    {
      // If UID of tag is matched.
      lcd.clear();
     Â
      tone(buzzer,2000);
      delay(200);
      noTone(buzzer);
     Â
      lcd.print("Card Detected :)");
      delay(1000);
      lcd.clear();
      lcd.print("Enter Pin:");
      lcd.setCursor(0, 1);
      RFIDMode = false; // Make RFID mode false
    }
    else
    {
      // If UID of tag is not matched.
      tone(buzzer,2000);
      delay(200);
      noTone(buzzer);
     Â
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Processing");
      delay(250);
      lcd.setCursor(10, 0);
      lcd.print(".");
      delay(250);
      lcd.setCursor(11, 0);
      lcd.print(".");
      delay(250);
      lcd.setCursor(12, 0);
      lcd.print(".");
       Â
      delay(250);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Processing");
      delay(250);
      lcd.setCursor(10, 0);
      lcd.print(".");
      delay(250);
      lcd.setCursor(11, 0);
      lcd.print(".");
      delay(250);
      lcd.setCursor(12, 0);
      lcd.print(".");
      Â
      lcd.clear();
     Â
      lcd.setCursor(0, 0);
      lcd.print("Card Invalid!");
     Â
      tone(buzzer,5000);
      delay(400);
      noTone(buzzer);
      delay(800);
     Â
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Please Scan a");
      lcd.setCursor(0, 1);
      lcd.print("Vaild Card.");
      delay(2000);
 Â
      lcd.clear();
    }
  }
  // If RFID mode is false, it will look for keys from keypad
  if (RFIDMode == false) {
    key_pressed = keypad_key.getKey(); // Storing keys
    if (key_pressed)
    {
      password[i++] = key_pressed; // Storing in password variable
      lcd.print("*");
    }
    if (i == 4) // If 4 keys are completed
    {
      delay(200);
      if (!(strncmp(password, initial_password, 4))) // If password is matched
      {
        lcd.clear();
       Â
        lcd.print("Pin Accepted.");
       Â
        tone(buzzer,2000);
        delay(200);
        noTone(buzzer);
        delay(500);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Processing");
        delay(250);
        lcd.setCursor(10, 0);
        lcd.print(".");
        delay(250);
        lcd.setCursor(11, 0);
        lcd.print(".");
        delay(250);
        lcd.setCursor(12, 0);
        lcd.print(".");
       Â
        delay(250);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Processing");
        delay(500);
        lcd.setCursor(10, 0);
        lcd.print(".");
        delay(250);
        lcd.setCursor(11, 0);
        lcd.print(".");
        delay(250);
        lcd.setCursor(12, 0);
        lcd.print(".");
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Take Your Cash");
        digitalWrite(motor, HIGH);
        delay(10000);
       Â
        delay(500);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Transaction");
        lcd.setCursor(0, 1);
        lcd.print("Completed.");
        digitalWrite(motor, LOW);
       Â
        while (myval<=90);
        myservo1.write(myval);
        myval = (myval + 1);
       Â
        tone(buzzer,2000);
        delay(700);
        noTone(buzzer);
       Â
        delay(2000);
       Â
        lcd.clear();
        i = 0;
        RFIDMode = true; // Make RFID mode true
      }
      else // If password is not matched
      {
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Wrong Pin");
        lcd.setCursor(0, 1);
        lcd.print("Entered :(");
       Â
        tone(buzzer,5000);
        delay(500);
        noTone(buzzer);
        delay(3000);
        lcd.clear();
        i = 0;
        RFIDMode = true; // Make RFID mode true
      }
    }
  }
}
Demo Video:
Comments