Laser Diode & LDR based alarm system using Arduino
In this Arduino electronics tutorial it is illustrated how to make laser based alarm system using Laser diode with LDR(Light Dependent Resistor). This can be useful to make security system for home usage or industrial application. It may also be useful in counting mechanism and control application. Arduino code for laser diode with LDR for alarm system is provided. Schematic wiring diagram of interfacing Arduino with LDR and buzzer, laser driver circuit with video demonstration are provided.
How it works
During normal operation, the laser beam from the laser diode hits the LDR. But when the laser beam is obstructed, LDR detects this because then it's resistance increases. This increase in resistance and hence increased voltage is detected by the Arduino ADC. When the increased voltage becomes higher than some pre-defined voltage at normal condition, alarm is sounded using a buzzer by the Arduino. Hence whenever intruder crosses the laser beam line, alarm is sounded.
Interfacing & Schematic wiring drawing of interfacing Arduino, LDR, buzzer and laser driver
Video demonstration of laser based alarm system
Arduino Code for Laser Diode LDR based alarm system
//Program for laserdiode based Alarm using LDR, Arduino, Buzzer
//Source: https://ee-diary.blogspot.com
const int ldrPin = A3;
const int buzzerPin = 4;
void setup(){
Serial.begin(9600); //set Serial output baud rate
pinMode(buzzerPin, OUTPUT);
//For output format
Serial.println("nADC value, Voltage(V):");
Serial.print("--------------------------------------------------n");
}
void loop() {
int ldrValue = analogRead(ldrPin);
float ldrVoltage = (ldrValue/1024.0)*5;
if(ldrValue > 300){
digitalWrite(buzzerPin, HIGH);
delay(500);
digitalWrite(buzzerPin, LOW);
delay(500);
}
else{
digitalWrite(buzzerPin, LOW);
}
Serial.println(String(ldrValue)+","+String(ldrVoltage)+"V");
delay(1000); //delay 2000ms to prevent any duplicates
}