Interfacing of LDR sensor with arduino using Tinkercad
In
this project, we are using LDR as a Light
Sensor with an Arduino to control a LED light and Buzzer as per light condition
of the room. The LED light and Buzzer will turns ON automatically when there is
less light intensity outside or inside the room
and turns off when it is bright
outside or inside the room. For this, we need LDR sensor to detect the light
intensity inside or outside the room. And an Arduino to control the Buzzer and
LED It’s like a dark detecting circuit.
Circuit Diagram:
Components Required:
§ Arduino UNO
§ LDR (Light Dependent Resistor)
§ Resistor (10k)
§ LED - 1
§ Buzzer Connecting wires
Connection:
The hardware a part of this project is
extremely easy to place together. First of all, make the connections for the
LDR sensor with the Arduino. The connections for the LDR sensor with the
Arduino given in above circuit diagram:
Connect one pin of the LDR sensor to the 5V
pin on the Arduino.
Connect another pin of LDR with resistor and
then connect it to the GND terminal of An Arduino.
Connect the LED anode pin to pin no 4 of an Arduino.
Connect the positive pin of the Buzzer to pin no
3 of an Arduino.
Connect the cathode of LED and negative of
Buzzer to the Arduino GND.
About LDR
Sensor :
LDR is a Light Dependent Resistor (LDR) is
also known as photo resistor or a cadmium sulfide (CdS) cell. It is a photocell
which works on the principle of photoconductivity. The principle is when the
intensity of light is more resistance value decreases and when the intensity of
light is less then resistance value increases. This type of sensor is mostly
used in light controlled sensor circuit, and light and dark detecting circuits.
Few practical applications of LDR smart
street lights, clock radios, light beam alarms, reflective smoke alarms, and
outdoor clocks.
LDR
Structure:
Advantages:
LDR’s are
cheap and are easily available in different sizes and shapes. Practical LDRs
are available in different packages and size. The most useful size having a
diameter of approximately 10 mm. it requires very small power and voltage for
its operation.
Disadvantages:
Very
inaccurate with a response time of about tens or hundreds of milliseconds.
Working of LDR controlled LED & Buzzer using Arduino:
As per the circuit
diagram, we have created a voltage divider across LDR using 10K resistor.
The output of voltage divider is connected to the analog input pin of an
Arduino. The analog Pin A0 reads the voltage and gives some analog value to
Arduino. The analog value varies according to the resistance of LDR. So, when
the light falls on the LDR the resistance of it gets decreased and due to that
the voltage value increase. we have stored this analog value in variable named
ldr and printed on serial monitor.
Intensity of light
decreases – Resistance increases - Voltage at analog pin decreases - LED turns ON.
Code Explanation (Block Based):
First of all, we declare variable named ldr, to store the light intensity value of a LDR sensor To declare the variable click on variable block and create variable, see the below picture.
After declaring the variable set variable to analog pin A0
Now we will use the main conditional statement
of the program that is ‘if’ block
In if block we will use the condition for that
we need the comparison operator here we have used the less than “<”
comparison operator.
Condition:
if the
ldr sensor value is less than 100 then pin 4 will be high and buzzer on pin no
3 will be on for 1 sec.
Arduino Sketch :
int ldr = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{
ldr = analogRead(A0);
Serial.println(ldr);
if
(ldr < 100) {
digitalWrite(4, HIGH);
tone(3, 523, 1000); // play tone 60 (C5 = 523 Hz)
}
else {
digitalWrite(4, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
Comments
Post a Comment
If you any query please comment