The Safe Room

Overview

This week, I designed a safe room using Arduino. The requirement was to create a circuit that will get information from at least one analog sensor and at least one digital sensor (switch) and use this information to control at least two LEDs, one in a digital fashion and the other in an analog fashion, in some creative way.

So, my creative idea involves a safe room that has a hidden secret controller. Every time someone enters the room, an intermediate warning is issued and the individual has 45 seconds to locate the hidden controller and adjust it to avoid triggering the security alarm. The location is highly confidential and only the top-tier managers know information. In case of an intruder, unless he is exceptionally smart enough to locate and adjust the controller, the person will be caught by this highly advanced security system.

Technical Implementation

One of the biggest challenges was to implement the idea on paper using the Arduino. After breaking into smaller steps, I figured it out. The digital switch was made using copper tape, one end on the board and one connected to the door. Once the door is open, it would send a HIGH to the connected digital input pin. Upon this, the always-on green light stops, and the yellow led starts glowing. Yellow led is controlled by the potentiometer (the controller). In the start it is set to a value of 1023 –  the bright yellow led and the individual has to switch off the led entirely using the potentiometer – to the value of 0. A timer is initiated as soon as the door is open and the individual has 45 seconds – 45000 milliseconds – to complete this. If the individual is successful, the green led turns back on. Otherwise, the red led is turned on digitally which signifies triggering the security alarm.

Here is the circuit:

Here’s the code:

//Global variable
const int knob = A0;
const int red_led = 13;
const int yellow_led = 11;
const int green_led = 8;
const int input = 7;
int starttime;

void setup() {
  //setting the modes
  pinMode(red_led, OUTPUT);
  pinMode(yellow_led, OUTPUT);
  pinMode(green_led, OUTPUT);
  pinMode(input, INPUT);

  //start timer
  starttime = millis();

  Serial.begin(9600);
  
}

void loop() {

  //when door is open
  if(digitalRead(input)==HIGH){
    //turn off the green led
    digitalWrite(green_led,LOW);
    //turn the yellow led on
    //control it anlogue way
    int knobValue = analogRead(knob);
    int mappedvalue = map(knobValue,0,1023,255,0);
    analogWrite(yellow_led,knobValue);

    //keep count of the time elapsed since the door is open
    Serial.print("millis elapsed : ");
    Serial.println(millis()-starttime);
    if((millis()-starttime) >= 45000){
      //if not controlled within time, trigger the alarm
      if(analogRead(knob) > 0){
        digitalWrite(red_led, HIGH);
      }
      //green switch back on successful completion
      else{
        digitalWrite(green_led, HIGH);
      }
    }
  }
  else{
    //if door closed, keep yellow light off and green on
    if(digitalRead(red_led) != HIGH){
      digitalWrite(yellow_led,LOW);
      digitalWrite(green_led,HIGH);
      Serial.println("You have 45 seconds to find and adjust the secret controller. Else alarm will go off!");
    }
  }

This is the video for when a known individual enters the room

This is in the case of an intruder

Leave a Reply