denisromancak
Published

ARDUINO Alarm 1.0

Hi, my name is Denis, today I will show you the production of the Alarm using the Arduino Uno R3 and the PIR motion sensor.

IntermediateProtip293
ARDUINO Alarm 1.0

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
Adafruit Keypad
×1
Resistor 220 ohm
Resistor 220 ohm
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Custom parts and enclosures

PCB

Schematics

Arduino Alarm circuit

Code

Arduino Alarm code

C/C++
#include <Keypad.h>

char* password = "123";  // change the password here, just pick any 3 numbers
int possition = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = { 7, 9, 8, 7 };
byte colPins[COLS] = { 6, 5, 4, 3 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );



int pir = 2;
int led = 12;
int sttate = 0;
int rep = 11;
int alarm = 0;
int ledZ = 13;

void setup(){
pinMode(2,INPUT_PULLUP);
pinMode(13,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
Serial.begin(9600);
LockedPosition(true);
}

void loop(){
char key = keypad.getKey();
  if (possition == 0)
    {
    LockedPosition(true);
}
if (key == '*' || key == '#')
{
possition = 0;
  }

if (key == password[possition])
{
possition ++;
}
if (possition == 3)
{
LockedPosition(false);
}
delay(100);
}
void LockedPosition(int locked)
{
if (locked){
sttate = digitalRead(pir);
if (sttate == HIGH)
  {
  alarm = 1;  
    }
if (alarm == 1 )  
 {
  digitalWrite(led,HIGH);
    analogWrite(rep,80);
  }
  
  Serial.println(sttate);
}
else {
    digitalWrite(led,LOW);
    analogWrite(rep,0);
  alarm = 0;
  LockedPosition(true); 
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  delay(500);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  delay(500);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  digitalWrite(ledZ,HIGH);
  delay(500);
  digitalWrite(ledZ,LOW);
  }
 }

Credits

denisromancak

denisromancak

0 projects • 0 followers

Comments