Zeeshan
Published

Simple Security System

This is very basic door security system which is using an eletromagnetic lock

BeginnerShowcase (no instructions)6 hours4,977
Simple Security System

Things used in this project

Story

Read more

Schematics

Main Circuit

j1 and J2 are proximity sensors installed at external door

Code

Access Controller

C/C++
This code activates a timer to make sure the external door is closed. Alarm is activated after timer expiry
#include <EEPROM.h>

int door1, door2, timer_cnt, chk;
boolean lock=true, alarm=false;

void setup() {
  pinMode(2,OUTPUT); //lock
  pinMode(4,OUTPUT); //alarm
  pinMode(12,INPUT); //proximity-1
  pinMode(13,INPUT); //proximity-2
  
  digitalWrite(2,HIGH);
  digitalWrite(4,LOW);
}

void loop() {
  door1=digitalRead(12);
  door2=digitalRead(13);
  if (door1 && door2){ //both doors closed
    digitalWrite(2,HIGH); //lock is activated
    timer_cnt=0;
  }
  else{ //one of doors is open
    digitalWrite(2,LOW); //lock is deactivated
    lock=false;
  }
  if (!lock){ //door is open
    timer_cnt=EEPROM.read(0);
    timer_cnt=timer_cnt+1;
    EEPROM.write(0, timer_cnt);
    chk=EEPROM.read(0);
    if (chk>=254 || alarm){ //timer is up
      digitalWrite(4,HIGH); //turn on alarm
      alarm=true;
    }
    else{
      digitalWrite(4,LOW); //turn off alarm
      alarm=false;
    }
  }
  else {
    timer_cnt=0;
    EEPROM.write(0, timer_cnt);
    lock=true;
  }
}

Credits

Zeeshan

Zeeshan

13 projects • 50 followers
Creative and destructive design master. Ability to use the brain waves for both construction and destruction

Comments