analoger
Published © MIT

Kitty bank

A safe bank for all your coins!

IntermediateFull instructions provided144
Kitty bank

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
RFID-RC522 module
×1
Push button (Generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Arduino UNO
Arduino UNO
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematics of this project

Code

Code to this project

C/C++
#include <Servo.h>
#include <MFRC522.h>
#include <SPI.h>

int SS_PIN = 10;
int RST_PIN = 9;
int green = 7;
int red = 6;
bool permission = false;
int reading_pin = A0;

int button_pin = 2;
int button_state = 0;

MFRC522 mfrc522 (SS_PIN, RST_PIN);
Servo servo;

void setup() {

  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(reading_pin, INPUT);
  pinMode(button_pin, INPUT);
  
  Serial.begin(9600);   // Initiate serial monitor
  mfrc522.PCD_Init();   // Initiate MFRC522
  SPI.begin();          // Initiate  SPI bus
  servo.attach(8);      //servo pin
  servo.write(0);       //servo start position
}

void loop() {
  // Kitty bank code
  if (permission == true) {
    if (analogRead(reading_pin) >= 1000) {
      servo.write(180);
      delay(1000);
      servo.write(0);
    }
  }

  // Lock the kitty bank if button is pressed
  button_state = digitalRead(button_pin);
  if (button_state == HIGH) {
    permission = false;
    digitalWrite(red, HIGH);
    delay(1000);
    digitalWrite(red, LOW);
  }

  // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }
  
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "F7 8D 9D 35") {
    Serial.println("Authorized access");
    Serial.println();

    digitalWrite(green, HIGH);
    delay(1000);
    digitalWrite(green, LOW);

    permission = true;
    
    delay(500);
  }
 
  else if (content.substring(1) != "F7 8D 9D 35") {
    Serial.println(" Access denied");

    permission = false;
    digitalWrite(red, HIGH);
    delay(1000);
    digitalWrite(red, LOW);
    
    delay(500);
  }
  
}

Credits

analoger
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.