LDR Arduino LM358 Alarm System

 Here is illustration of how to make LDR and Arduino based alarm system. The detection system works with LM358 operational amplifier which is used as comparator here. Two LEDs, green and red, are used for visual indication of absence or presence of light source at the LDR(Light Dependent Resistor). The Arduino is used to monitor the output from the LM358 and alert the state of the output to the serial monitor.

 The following is the circuit diagram of how this works.

LDR Arduino LM358 Alarm System

The LDR with 10Kohm resistor are connected to LM358 operational amplifier +ve terminal pin 3 and a 10KOhm Potentiometer is connected to the -ve terminal 2 of the LM358. When the LDR receives sufficient light from some kind of light source such as from laser as illustrated in the tutorial Laser Diode & LDR based alarm system using Arduino or ambient light from the surrounding, the voltage at the +ve terminal gets higher than the -ve terminal then the output from the LM358 is high. At the output two LED, green and red are connected. When there is no light detection by the LDR then the output is low and the green LED is turned on which is the normal condition. When there is light detection then the output is high and the red LED is turned on. 

Arduino is used to monitor the output and send message to the serial port. The message is either OFF or ON depending upon whether the output is LOW or HIGH. Any message can be used. The following is the Arduino Program.


const int ldrPin = 2;  // LDR pin

void setup () {
  pinMode(ldrPin, INPUT);
  Serial.begin(9600);
}

void loop(){
  if (digitalRead(ldrPin) == HIGH){
    Serial.println("ON");
  }
  else{  
    Serial.println("OFF");
  }
}

The following video demonstrates how this system works.

In this LDR Arduino example, we have used LM358 which outputs either LOW or HIGH digital signal which is then captured using digital pin of Arduino. Alternatively we can also use the analog pin to capature the input voltage and write program to alert user when the light intensity threshold detected by the LDR is exceeded. This is illustrated in the tutorial Interfacing LDR(Light Dependent Resistor) and Arduino Nano. Also in that LDR  Arduino tutorial there is no need for LM358 comparator. This LDR system can be easily integrated into web based application with Node Red as illustrated in the tutorial IR proximity with Audio Warning in Node Red.

Post a Comment

Previous Post Next Post