Arduino LDR sensor Laser Tripwire Security Alarm



Hardware Required

  • Arduino Uno
  • LED
  • LDR (photo resistor) , Light Dependent Resistor
  • 220 and 10k ohm resistors
  • Wires
  • Breadboard
  • Buzzer
  • Laser Module


Schematic diagram



LED connection

  1. LED attach to board
  2. Resistor (220 ohm) one leg attach to LED long leg
  3. The green wire attach to resistor's empty leg → Arduino D13
  4. The black wire attach o LED short leg → Arduino GND

LDR Connection

  1. LDR attach to board
  2. Resistor (10k ohm) attach to LDR one leg
  3. The Black wire attach to LDR other (empty) leg → Arduino Gnd
  4. The Yellow wire attach to LDR and resistor same column → Arduino A0
  5. The Red wire attach to resistor empty leg → Arduino 5V

Buzzer Connection

1. Buzzer + to pin 12 on Arduino
2. Buzzer -  to GND on Arduino

Laser Module Connection

1. Laser module +/s to pin 7 on Arduino
2. Laser module - to GND on Arduino


Arduino Sketch


const int ledPin = 13;

const int buzzerPin = 12;

const int ldrPin = A0;
const int laserPin = 7;

void setup () {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(buzzerPin, OUTPUT);

pinMode(ldrPin, INPUT);
pinMode( laserPin , OUTPUT);

digitalWrite( laserPin , HIGH);

}

void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldrStatus < 700) {

tone(buzzerPin, 100);

digitalWrite(ledPin, HIGH);

delay(100);

noTone(buzzerPin);

digitalWrite(ledPin, LOW);

delay(100);

Serial.println(" ALARM ACTIVATED ");

}

else {

noTone(buzzerPin);

digitalWrite(ledPin, LOW);

Serial.println("ALARM DEACTIVATED");

}
Serial.println( ldrStatus );
//delay(10);
}


ความคิดเห็น