Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <MFRC522.h>
- #define SS_PIN 53
- #define RST_PIN 9
- #define BUZZER 22
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
- String store ;
- int s=0;
- #include <SoftwareSerial.h>
- int bluetoothTx =10; // bluetooth tx to 10 pin
- int bluetoothRx =11;// bluetooth rx to 11 pin
- String input;
- boolean isVerified=false;
- SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- bluetooth.begin(9600);
- bluetooth.flush();
- Serial.print("isVerified = "); Serial.println(isVerified);
- SPI.begin(); // Initiate SPI bus
- mfrc522.PCD_Init(); // Initiate MFRC522
- pinMode(BUZZER, OUTPUT);
- noTone(BUZZER);
- Serial.println("Put your card to the reader...");
- Serial.println();
- }
- void loop() {
- if ( ! mfrc522.PICC_IsNewCardPresent())
- {
- return;
- }
- // Select one of the cards
- if ( ! mfrc522.PICC_ReadCardSerial())
- {
- return;
- }
- 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) == "D3 C3 C8 1C") //change here the UID of the card/cards that you want to give access
- {
- store=content.substring(1);
- Serial.println("Authorized access");
- isVerified=true;
- Serial.println();
- delay(100);
- tone(BUZZER, 2100);
- delay(100);
- tone(BUZZER, 2300);
- delay(100);
- tone(BUZZER, 2200);
- noTone(BUZZER);
- delay(200);
- }
- Serial.print("isVerified = "); Serial.println(isVerified);
- if (isVerified) {
- Serial.println("Inside isVerified Loop");
- while(bluetooth.available()>0){
- Serial.println("Inside BT Read Loop");
- char c=bluetooth.read();
- input+=c;
- Serial.println(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement