Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <MFRC522.h>
- String card[2] = {
- "A0 EA 57 32" // ---> Valid
- ,
- "A9 C0 15 BA" // ---> Valid
- };
- const int microwavePin = 4;
- const int buzzerPin = 8;
- const int ledPin = 7;
- String a = "";
- MFRC522 mfrc522(10, 9);
- int count = 0;
- bool seats[2] = {0};
- int out = 0;
- void setup() {
- Serial.begin(115200); // Initiate a serial communication
- pinMode(6, OUTPUT);
- digitalWrite(6, 1);
- pinMode(buzzerPin, OUTPUT);
- pinMode(microwavePin, INPUT);
- pinMode(ledPin, OUTPUT);
- SPI.begin(); // Initiate SPI bus
- mfrc522.PCD_Init(); // Initiate MFRC522
- Serial.print("starting");
- }
- void loop() {
- // Look for new cards
- if ( ! mfrc522.PICC_IsNewCardPresent())
- {
- return;
- }
- // Select one of the cards
- if ( ! mfrc522.PICC_ReadCardSerial())
- {
- return;
- }
- String content = "";
- byte letter;
- for (byte i = 0; i < mfrc522.uid.size; i++)
- {
- // To show cards UUID, un-comment the next line
- content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
- content.concat(String(mfrc522.uid.uidByte[i], HEX));
- }
- content.toUpperCase();
- Serial.println(content.substring(1));
- for (int j = 0; j < 2; j++) {
- if (content.substring(1) == card[j]) //change UID of the card that you want to give access
- {
- buzz();
- delay(1000);
- while (1) {
- int microwave = digitalRead(microwavePin);
- if (microwave == 1) {
- digitalWrite(ledPin, HIGH);
- Serial.println(microwave);
- //buzz();
- }
- else {
- digitalWrite(ledPin, LOW);
- digitalWrite(6, 0);
- Serial.println(microwave);
- break;
- }
- }
- }
- }
- }// end of loop
- void buzz() {
- digitalWrite(buzzerPin, 1);
- delay(100);
- digitalWrite(buzzerPin, 0);
- delay(50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement