Sheanna AllenRhea LawhornNicholas Carranza
Published

Homemade Alarm System

This is a way to create your own alarm system without paying all the extra cash.

BeginnerFull instructions provided6 hours379
Homemade Alarm System

Things used in this project

Hardware components

Photon
Particle Photon
×3
Buzzer
Buzzer
×1
Breadboard (generic)
Breadboard (generic)
×3
Amazon Web Services Magnetic Reed Switched
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Fritzing
Maker service
IFTTT Maker service

Story

Read more

Schematics

Buzzer Schematic

These are the connections for the buzzer.

Magnetic Reed Switch Sensor

This is the connection for the Magnetic Reed Switch. The image was created on Fritzing.

Code

Front Door Code

C/C++
Magnetic reed switch remains intact when the front door is closed. Once the front door opens, the magnetic reed switch is separated and relays this information to the buzzer.
 int inswitc = D1;               // choose the input pin (for reed swtich)
 int pirStat = 0;             // we start with the door/window closed
 int vals = 0;                    // variable for reading the pin status
  
void setup() {
  
  pinMode(inswitc, INPUT);     // declare switch as input
Particle.variable("pirStat", &pirStat, INT);
    Particle.variable("vals", &vals, INT);
    
    
 
}
 
void loop(){
  vals = digitalRead(inswitc);  // read input value
  if (vals == 1) {            // check if the input is HIGH
    
    
     Particle.publish("Window_stat","Open");
     delay(12000);
  }   
     
   else if (vals == 0) {
         
         Particle.publish("Window_stat","closed");
     
   
      
     delay(12000);

  }
}

Back Door Code

C/C++
Magnetic reed switch remains intact when the back door is closed. Once the back door opens, the magnetic reed switch is separated and relays this information to the buzzer.
 int inswitch = D1;               // choose the input pin (for reed swtich)
 int pirState = 0;             // we start with the door/window closed
 int val = 0;                    // variable for reading the pin status
  
void setup() {
  
  pinMode(inswitch, INPUT);     // declare switch as input
Particle.variable("pirState", &pirState, INT);
    Particle.variable("val", &val, INT);
    
    
 
}
 
void loop(){
  val = digitalRead(inswitch);  // read input value
  if (val == 1) {            // check if the input is HIGH
    
    
     Particle.publish("Door_state","Open");
     delay(12000);
  }   
     
   else if (val == 0) {
         
         Particle.publish("Door_state","closed");
     
   
      
     delay(12000);

Buzzer Sensor Code

C/C++
This is the code to get the buzzer working and connect it to the Switches.
void setup()
{                
    pinMode(D1, OUTPUT);  // buzzer on pin D1
    Particle.subscribe("Window_stat",myHandler);
     Particle.subscribe("Door_stat",myHandler);
}

void myHandler(const char *event, const char *data)
{
    if (strcmp(data,"Open")==0)
    {
        digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);
        delay(200);digitalWrite(D1,LOW);delay(50);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);
        delay(400);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(100);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(2000);
        //series 2
        digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);
        delay(200);digitalWrite(D1,LOW);delay(50);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(200);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);
        delay(400);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(100);digitalWrite(D1,HIGH);delay(200);digitalWrite(D1,LOW);delay(2000);
       
    }
    
    else
    {
    delay(100);
    }
}

Credits

Sheanna Allen

Sheanna Allen

1 project • 0 followers
Rhea Lawhorn

Rhea Lawhorn

1 project • 0 followers
Nicholas Carranza

Nicholas Carranza

1 project • 0 followers

Comments

Add projectSign up / Login