|
| 1 | +//*LCD INITIALIZATION*// |
| 2 | +#include <LiquidCrystal.h> |
| 3 | +const int rs=47,rw=46, en=45, d0=44, d1=43, d2=42, d3=41, d4 = 40, d5 = 39, d6 = 38, d7 = 37; |
| 4 | +LiquidCrystal lcd(rs, rw,en,d0,d1,d2,d3, d4, d5, d6, d7); |
| 5 | + |
| 6 | +int j=0; |
| 7 | +int i=0; |
| 8 | +int buzzer=31; |
| 9 | +int LED1=22; |
| 10 | +int LED2=23; |
| 11 | +//*BLUETOOTH INITIALIZATION*// |
| 12 | +char c[4]; |
| 13 | +int count1=0; |
| 14 | +char a[4]={'0','7','0','1'}; |
| 15 | +//*RFID INITIALIZATION*// |
| 16 | +char input[12]={'5','4','0','0','6','A','E','C','7','4','A','6'}; |
| 17 | +char b[12]; |
| 18 | +int count=0; |
| 19 | + |
| 20 | +//*MOTOR INITIALIZATION*// |
| 21 | +int Motor1=33; |
| 22 | +int Motor2=34; |
| 23 | + |
| 24 | +void setup() { |
| 25 | + lcd.begin(16,2); //SELECTING LCD COLUMNS & ROWS |
| 26 | + Serial.begin(9600); //INITALIZING SERIAL COMMUNICATION |
| 27 | + Serial2.begin(9600); //INITALIZING BLUETOOTH SERIAL COMMUNICATION |
| 28 | + Serial3.begin(9600); //INITALIZING RFID SERIAL COMMUNICATION |
| 29 | + pinMode(Motor1,OUTPUT); //DIFINING MOTOR1 AS OUTPUT DEVICE |
| 30 | + pinMode(Motor2,OUTPUT); //DIFINING MOTOR2 AS OUTPUT DEVICE |
| 31 | + pinMode(LED1,OUTPUT); //DIFINING LED1 AS OUTPUT DEVICE |
| 32 | + pinMode(LED2,OUTPUT); //DIFINING LED21 AS OUTPUT DEVICE |
| 33 | + pinMode(buzzer,OUTPUT); //DIFINING BUZZER AS OUTPUT DEVICE |
| 34 | + digitalWrite(LED1,HIGH); //INITIALIZING LED1 OFF |
| 35 | + digitalWrite(LED2,HIGH); //INITIALIZING LED2 OFF |
| 36 | + digitalWrite(Motor1,LOW); //INITIALIZING MOTOR1 OFF |
| 37 | + digitalWrite(Motor2,LOW); //INITIALIZING MOTOR2 OFF |
| 38 | + while(i!=3){ //MAKING MSG BLINK FOR 3 TIMES |
| 39 | + lcd.noDisplay(); |
| 40 | +delay(500); |
| 41 | +lcd.display(); |
| 42 | + lcd.print("! RFID BANK ! "); |
| 43 | + lcd.setCursor(0,1); |
| 44 | + lcd.print("SCAN YOUR CARD "); |
| 45 | + delay(500); |
| 46 | + i++; |
| 47 | +}} |
| 48 | + |
| 49 | +void loop() { |
| 50 | + if (Serial3.available()){ //IF RFID TAG IS AVAILABLE TO SCAN |
| 51 | + b[count]=Serial3.read(); //SCAN THE TAG AND STORE THE VALUE IN ARRAY 'b' |
| 52 | + count++; |
| 53 | + } |
| 54 | + if(count==12) //IF SCANNED ARRAY VALUE IS OF 12 DIGITS ENTER IN THE LOOP |
| 55 | + { |
| 56 | + if(strncmp(b,input,12)==0) //COMPARING STRING BETWWEN STORED AND SCANNED VALUE |
| 57 | + { |
| 58 | + lcd.clear(); //MAKING LCD CLEAR FOR PRINTING |
| 59 | + lcd.write("Access Granted"); //LCD OUTPUT |
| 60 | + delay(500); |
| 61 | + digitalWrite(LED1,LOW); //LED1 ON |
| 62 | + digitalWrite(buzzer,HIGH); //BUZZER ON |
| 63 | + delay(500); |
| 64 | + digitalWrite(LED1,HIGH); //LED1 OFF |
| 65 | + digitalWrite(buzzer,LOW); //BUZZER OFF |
| 66 | + |
| 67 | + Serial2.println("PLEASE ENTER PASSCODE THROUGH MOBILE"); //PRINTING OUTPUT ON BLUETOOTH TERMINAL THROUGH BLUETOOTH |
| 68 | + lcd.clear(); |
| 69 | + lcd.write("ENTER PASSWORD"); |
| 70 | + while(count1!=4){ |
| 71 | + if (Serial2.available()){ |
| 72 | + c[count1]=Serial2.read(); //READ THE VALUE THROUGH BLUETOOTH AND STORE IN STRING 'c' |
| 73 | + Serial.println(c[count1]); |
| 74 | + count1++; |
| 75 | + |
| 76 | + }} |
| 77 | + if(count1==4) |
| 78 | + { //IF THE EBTERD PASSWORD IS EQAUL TO 4, THEN ENTER |
| 79 | + if (strncmp(c,a,4)==0) //COMPARING STRING BETWWEN STORED AND SCANNED VALUE |
| 80 | + { lcd.clear(); |
| 81 | + lcd.write("WELCOME SIR"); //LCD FINAL OUTPUT |
| 82 | + Serial2.println("WELCOME SIR"); //BLUETOOTH PRINT ON TERMINAL |
| 83 | + digitalWrite(Motor1,HIGH); //MOTOR1 ON |
| 84 | + delay(1000); |
| 85 | + digitalWrite(Motor1,LOW); //MOTOR1 ON |
| 86 | + digitalWrite(Motor2,HIGH); //MOTOR2 ON |
| 87 | + delay(1000); |
| 88 | + digitalWrite(Motor2,LOW); //MOTOR2 OFF |
| 89 | + digitalWrite(LED2,LOW); //LED2 ON |
| 90 | + delay(500); |
| 91 | + digitalWrite(LED2,HIGH); //LED2 OFF |
| 92 | + count1=0; //RESETTING THE COUNT1=0 FOR PASSWORD ENTERING |
| 93 | + } |
| 94 | + else{lcd.clear(); |
| 95 | + lcd.write("WRONG PASSWORD"); //IF ENTERED PASSWORD IN INCORRECT, PRINT ON LCD |
| 96 | + Serial2.println("WRONG PASSWORD"); //IF ENTERED PASSWORD IN INCORRECT, PRINT ON BLUETOOTH TERMINAL |
| 97 | + count1=0;} |
| 98 | + } |
| 99 | + count=0;} //RESETTING THE COUNT=0 FOR THE NEXT SCAN & STORE |
| 100 | + else |
| 101 | + {lcd.clear(); |
| 102 | + lcd.write("Access Denied"); //IF TAG READ VALUE IS MISMATCH, PRINT THIS ON LCD |
| 103 | +count=0;}}} |
| 104 | + |
0 commit comments