Introduction: Arduino Anti-thief System

Hey guys, today I will show you how to make an arduino anti-thief system.

Firstly, I am sorry about my grammar. I am 14 years old and I'm from Vietnam. This is my first project and instructable, too.

Step 1: Materials

Picture of Materials
  1. An Arduino Uno R3.
  2. An PIR sensor (Passive InfraRed sensor).
  3. A speaker (You use a small one).
  4. A LED light.
  5. A laptop to program the Arduino.

Step 2: Wire Connection

Picture of Wire Connection

You connect like this:

  • Connect GND pin of the sensor with GND pin of the Arduino.
  • Connect VCC pin of the sensor with 5V pin of the Arduino.
  • Connect OUT pin of the sensor with pin number 2 of the Arduino.

Step 3: Program Arduino Code

OK, you download arduino on website arduino.com then copy and paste this code:

int ledPin = 13;

int inputPin = 2;

int pirState = LOW;

int val = 0;

int pinSpeaker = 10;

void setup()

{

pinMode(ledPin, OUTPUT);

pinMode(inputPin, INPUT);

pinMode(pinSpeaker, OUTPUT);

Serial.begin(9600);

}

void loop()

{

val = digitalRead(inputPin);

if (val == HIGH)

{

digitalWrite(ledPin, HIGH);

On playTone(300, 160);

delay(150);

if (pirState == LOW)

{

Serial.println("Motion detected!");

pirState = HIGH;

}

}

else

{

digitalWrite(ledPin, LOW);

playTone(0, 0);

delay(300);

if (pirState == HIGH)

{

Serial.println("Motion ended!");

pirState = LOW;

}

}

}

void playTone(long duration, int freq)

{

duration *= 1000;

int period = (1.0 / freq) * 1000000;

long elapsed_time = 0;

while (elapsed_time < duration)

{

digitalWrite(pinSpeaker,HIGH);

delayMicroseconds(period / 2);

digitalWrite(pinSpeaker, LOW);

delayMicroseconds(period / 2);

elapsed_time += (period);

}

}

Comments

Ashutosh KumarU (author)2016-05-23

nice and cool one

VUNAMANH8112 made it! (author)2016-05-16

I am sorry but if you do not want to connect to computer, you can use ultra fire battery

AmCoder (author)2016-05-15

good job

DIY Hacks and How Tos (author)2016-05-15

Cool security system.