LDR Buzzer Using Node

by goks_lf in Circuits > Arduino

2552 Views, 1 Favorites, 0 Comments

LDR Buzzer Using Node

a.png

Hi!! I am Gokul, back with another series of tutorials on Node MCU today.This project deal with LDR buzzer i.e if there are any changes in light there is a ping in the buzzer.This ibles is used during the day time in while we are away from our home and integrate the IoT platform to reveal the suspicious activity.Let's now get started by collecting the components.

Components Required

a1.png
a2.png
a3.png
a4.png
a5.png

components required can be observed above:

  • Node MCU
  • Buzzer
  • Breadboard
  • Light dependent resistor

LDR Connection

IMG_20170824_195809.jpg
IMG_20170824_195833.jpg
IMG_20170824_195920.jpg

LDR is a light dependent resistor that resistance is increased when there is increase is decrease in the light rays around the surface

The connection of the LDR is as follows:

  • One leg of the LDR is connected to the GND through 10 k resistor
  • The same leg is connected to the analog pin A0.
  • Another leg is connected to the 3.3 volt of the Node MCU.

Buzzer

IMG_20170824_200132.jpg
IMG_20170824_200142.jpg
IMG_20170824_200204.jpg
IMG_20170824_200320.jpg

Buzzer is an electronic device which is used to convert the electrical impulse sent as input to a sound energy.

The buzzer has two polarities but in the form of wires(red wire and black wire).

The connection of the buzzer is as follows:

  • The red wire is connected to digital pin 2.
  • The black wire is connected to the GND pin of the Node MCU.

Coding

a6.png
const int buzzerPin = 2;const int ldrPin = A0; 
void setup () { 
Serial.begin(9600); 
pinMode(buzzerPin, OUTPUT); 
pinMode(ldrPin, INPUT); 
}int ldrStatus = analogRead(ldrPin); 
if (ldrStatus >= 400) { 
tone(buzzerPin, 100); delay(100); 
noTone(buzzerPin); 
delay(100);
 }void loop() {int ldrStatus = analogRead(ldrPin); 
if (ldrStatus >= 400) { 
tone(buzzerPin, 100); 
delay(100); 
noTone(buzzerPin); 
delay(100);
 }else {
noTone(buzzerPin);
} }

Output

IMG_20170824_200932.jpg