Components and supplies
9V Power Supply
Buzzer
IR receiver (generic)
Breadboard (generic)
Arduino UNO
MFRC522
SG90 Micro-servo motor
5 mm LED: Red
Jumper wires (generic)
5 mm LED: Green
Tools and machines
Silicon
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
Code
arduino
1/// This project was made by Mehmet Efe Peker. 2#include <RFID.h> 3#include <SPI.h> 4#include <Servo.h> 5 6#define SS_PIN 10 7#define RST_PIN 9 8 9#define SERVO_PIN 8 10 11#define kirmizi 2 12#define yesil 3 13 14#define buzzer 7 15 16int ir_deger; 17 18Servo servo; 19RFID rfid(SS_PIN, RST_PIN); 20 21boolean kart = false; 22 23int rfid_id[5] = {10,28,87,46,111}; 24 25int ir = 5; 26 27boolean kilit = false; 28 29 30void kapiyi_kapat() { /// Closes the door. 31 if(kilit = true){ 32 servo.write(0); 33 Serial.println("Door closed."); 34 delay(100); 35 servo.write(180); 36 } 37} 38 39 40void setup() { 41 pinMode(kirmizi, OUTPUT); 42 pinMode(yesil, OUTPUT); 43 pinMode(buzzer, OUTPUT); 44 pinMode(ir, OUTPUT); 45 servo.attach(SERVO_PIN); 46 Serial.begin(9600); 47 SPI.begin(); 48 rfid.init(); 49} 50 51void loop() { 52 kart = true; 53 servo.write(0); 54 Serial.println("Hold the Card."); 55 if(rfid.isCard()){ 56 if(rfid.readCardSerial()){ 57 Serial.print("ID: "); 58 delay(100); 59 } 60 for (int i = 0; i<5; i++){ 61 Serial.print(rfid.serNum[i]); 62 Serial.print(""); 63 delay(100); 64 } 65 for (int i = 0; i<5; i++){ 66 if(rfid_id[i] != rfid.serNum[i]){ 67 kart = false; 68 tone(buzzer, 3); 69 delay(1000); 70 noTone(buzzer); 71 Serial.println("Wrong ID."); 72 delay(1000); 73 return; 74 } 75 } 76 Serial.println(); 77 delay(1000); 78 Serial.println("Welcome to your rome"); 79 delay(1000); 80 digitalWrite(yesil, HIGH); 81 delay(200); 82 digitalWrite(kirmizi, LOW); 83 tone(buzzer, 3); 84 delay(1000); 85 noTone(buzzer); 86 delay(100); 87 servo.write(180); 88 delay(2000); 89 Serial.println("Door opened."); 90 delay(10000); 91 kapiyi_kapat(); 92 ir_deger = digitalRead(ir); 93 if (ir_deger <= 500){ 94 servo.write(0); 95 Serial.println("Door closed."); 96 } 97 else{ 98 return; 99 } 100 } 101 }
Code
arduino
1/// This project was made by Mehmet Efe Peker. 2#include <RFID.h> 3#include 4 <SPI.h> 5#include <Servo.h> 6 7#define SS_PIN 10 8#define RST_PIN 9 9 10#define 11 SERVO_PIN 8 12 13#define kirmizi 2 14#define yesil 3 15 16#define buzzer 7 17 18int 19 ir_deger; 20 21Servo servo; 22RFID rfid(SS_PIN, RST_PIN); 23 24boolean kart 25 = false; 26 27int rfid_id[5] = {10,28,87,46,111}; 28 29int ir = 5; 30 31boolean 32 kilit = false; 33 34 35void kapiyi_kapat() { /// Closes the door. 36 if(kilit 37 = true){ 38 servo.write(0); 39 Serial.println("Door closed."); 40 delay(100); 41 42 servo.write(180); 43 } 44} 45 46 47void setup() { 48 pinMode(kirmizi, 49 OUTPUT); 50 pinMode(yesil, OUTPUT); 51 pinMode(buzzer, OUTPUT); 52 pinMode(ir, 53 OUTPUT); 54 servo.attach(SERVO_PIN); 55 Serial.begin(9600); 56 SPI.begin(); 57 58 rfid.init(); 59} 60 61void loop() { 62 kart = true; 63 servo.write(0); 64 65 Serial.println("Hold the Card."); 66 if(rfid.isCard()){ 67 if(rfid.readCardSerial()){ 68 69 Serial.print("ID: "); 70 delay(100); 71 } 72 for (int i = 73 0; i<5; i++){ 74 Serial.print(rfid.serNum[i]); 75 Serial.print(""); 76 77 delay(100); 78 } 79 for (int i = 0; i<5; i++){ 80 if(rfid_id[i] 81 != rfid.serNum[i]){ 82 kart = false; 83 tone(buzzer, 3); 84 delay(1000); 85 86 noTone(buzzer); 87 Serial.println("Wrong ID."); 88 delay(1000); 89 90 return; 91 } 92 } 93 Serial.println(); 94 delay(1000); 95 96 Serial.println("Welcome to your rome"); 97 delay(1000); 98 digitalWrite(yesil, 99 HIGH); 100 delay(200); 101 digitalWrite(kirmizi, LOW); 102 tone(buzzer, 103 3); 104 delay(1000); 105 noTone(buzzer); 106 delay(100); 107 servo.write(180); 108 109 delay(2000); 110 Serial.println("Door opened."); 111 delay(10000); 112 113 kapiyi_kapat(); 114 ir_deger = digitalRead(ir); 115 if (ir_deger 116 <= 500){ 117 servo.write(0); 118 Serial.println("Door closed."); 119 120 } 121 else{ 122 return; 123 } 124 } 125 }
Downloadable files
Schematics
Schematics
Schematics
Schematics
Circuit Diagram
Circuit Diagram
Comments
Only logged in users can leave comments