Midterm Week!
Me and Sid will do collaboration with the Halloween Musical Theatre. And we both chose to work with the idea of the lock box that we both are interested with. After talking to Rob who is in charge of the part of the theatre, we were all agree fit in the idea of make a RFID lock boxes for people to find and open. And the interaction between audiences and the box will be finding that box and try to open it with different IDs, and the LEDs that outside the box will be the indicators of success or failure. 
During our discussion, we talked about different interactions between audiences and the box. Because they want to hide the box, so the attraction of the box won't be happened. Also, inside the box we put the right light, for the audience to be noticed that they successfully opened it. 
And the next step will be try RFID with electronic magnet locks. 
Firstly, we use the RFID to give it a try, which is different than the MFRC522 that we are going to use in the end. And it worked well. However, when we got the MFRC522 reader, the code and library is different. Here is the code: 

//I learnt it from Youtuber patrickikis
#include <require_cpp11.h>
#include <MFRC522.h>
#include <deprecated.h>
#include <MFRC522Extended.h>

//RFID
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 4 //define green LED pin
#define LED_R 5 //define red LED
const int lock = 2;  //meg lock's pin
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 
void setup() 
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(lock,OUTPUT);
  Serial.println("Put your card to the reader...");
  Serial.println();
}
void loop() 
{
  digitalWrite(lock, HIGH);
  // Look for new cards
  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) == "6C 13 DA C3"||content.substring(1) == "CC AD DA C3") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    digitalWrite(LED_G, HIGH);
    digitalWrite(lock, LOW);
    delay(5000);
    digitalWrite(LED_G, LOW); 
  }
 
 else   {
    Serial.println(" Access denied");
    digitalWrite(lock, HIGH);
    for (int i = 0; i < 3; i++){
          digitalWrite(LED_R, HIGH);
    delay(150);
    digitalWrite(LED_R, LOW);
    delay(150);
    }
    digitalWrite(LED_R, HIGH);
    delay(30000);
    digitalWrite(LED_R, LOW);
  }
}


// we added lock and led functions in that code

Then we figured out that the dv power of the electronic magnet locks can be linked directly to the board ( thanks to Amika!) Then we got the wires as simple as possible.

finally, we tried to design the keys for the box, so that audiences can be intuitively guided to unlock it. What we did is that we traced the pattern on the box, below the pattern will be the RFID reader, and then made it into a key.
Here is the pattern of the key.
Back to Top