You are on page 1of 14

LDR and SOUND SENSOR

LAB 6

Didam Ahmed
LDR(LIGHT DEPENDENT
RESISTOR)
A light dependent resistor (LDR) or a photo resistor or
photocell is a light controlled variable resistor .
Its resistance changes with Light intensity that falls on it.

The resistance of a photo resistor decreases with increasing


Incident light intensity.
CHARACTERESTICS OF LDR
LDRs are light dependent device whose resistance decreases
when light falls on them and increases in the dark.

When a light dependent resistor is kept in dark , its resistance is


very high . This resistance is called as dark resistance.

It can be as high as 1012Ω .

LDR are less sensitive than photo diodes and photo transistor
CHARACTERESTICS OF LDR
A photo diode and a photocell (LDR) are not the same a
photodiode is a semiconductor device that converts light to
electricity.

where as a photocell is a passive device , there is no nor it


converts light to electricity.
If the light intensity is kept constant , the resistance may
still vary significantly due to temperature changes.
APPLICATION OF LDR
1. Light sensor
2. Fire Alarm
3. Automatic street light
Project
Hardware Required
1. Arduino or Genuino board
2. LED
3. analog sensor (a photoresistor will do)
4. 10k ohm resistor
5. 220 ohm resistor
6. hook-up wires (jumpers)
7. breadboard
Circuit
Code
int ledPin = 9;   //the number of the LED pin
int ldrPin = A0;  //the number of the LDR pin
void setup() {
  pinMode(ledPin, OUTPUT);  //initialize the LED pin as an output

void loop() { 
  int ldrStatus = analogRead(ldrPin);   //read the status of the LDR value
//check if the LDR status is <= 300
 //if it is, the LED is HIGH
   if (ldrStatus <=300) {    
  digitalWrite(ledPin, LOW);               //turn LED on
   }
  else
{    
  digitalWrite(ledPin, HIGH);          //turn LED off
      }
}
SOUND SENSOR
The sound sensor module provides an easy way to detect
sound and is generally used for detecting sound intensity.

 This module can be used for security, switch, and


monitoring applications. Its accuracy can be easily adjusted
for the convenience of usage.
Pin Configuration
1. VCC: 3.3V-5V DC
2. GND: ground
3. DO: digital output
4. AO: analog output
Project
sensor detects sound and light up an LED.
1. Arduino
2. A Sound Sensor
3. LED
4. 220 ohm Resistors
5. Breadboard
6. Wires
Circuit
Code For Digital pin
int soundSensor = 2;
int LED=3;
void setup()
{
pinMode(soundSensor,INPUT);
pinMode (LED,OUTPUT);
}
void loop()
{
int statusSensor = digitalRead (soundSensor);
if (statusSensor == 1)
{
digitalWrite(LED, LOW);
}else
{
digitalWrite(LED, HIGH);
}
}
Code For Analogue Input
int ledpin=13; // led pin and sound pin are not changed throughout the process
int soundpin=A2;
int threshold=200; // sets threshold for sound sensor
void setup () {
pinMode(ledpin, OUTPUT);
pinMode(soundpin, INPUT);
}
void loop () {
int soundsens=analogRead(soundpin); //read analog data from sensor
if (soundsens>=threshold) {
digitalWrite(ledpin, HIGH); // turns led on
delay(1000);
}
else{
digitalWrite(ledpin, LOW);
}
}

You might also like