Laboratory Activity 2
Laboratory Activity 2
Laboratory Activity 2
Light Intensity Measurement and Control
Section: ____________
Objectives:
1. Measure and display light intensity using LDR sensor and an 16x2 LCD display.
2. Indicate in the display whether the light intensity is very dark, dark, bright and very bright.
3. Control the operation of a light bulb based on the sensor’s threshold level.
Theory:
A photo resistor or light-dependent resistor (LDR) or photocell is a light-controlled variable resistor. The
resistance of a photo resistor decreases with increasing incident light intensity; in other words, it exhibits
photoconductivity. We can use this variation to measure, through analog inputs, an estimate of the light
level.
A photo resistor is made up of a semiconductor, typically cadmium sulfide CdS. When the light falls on it,
some of the photons are absorbed, causing electrons to pass into the conduction band and, therefore,
decreasing the resistance of the component.
Thus, a photo resistor decreases in resistance as the light on it increases. Typical values are 1 MΩ in total
darkness, to 50-100 Ω under bright light.
On the other hand, the resistance variation is relatively slow, from 20 to 100 ms depending on the model.
This slowness means that it is not possible to record rapid variations, such as those produced by artificial
light sources powered by alternating current. This behavior can be beneficial since it gives the sensor great
stability.
Finally, photo resistors are not suitable to provide an illuminance measurement, that is, to serve as a lux
meter. This is due to their low precision, their strong dependence on temperature, and, especially, their
spectral distribution is not suitable for the illuminance measurement.
To calibrate the light detection circuit, you can adjust the values of the resistors in the voltage divider
circuit connected to the photoresistor. By measuring the output voltage of the voltage divider at different
light levels, you can determine the threshold values for light detection. We can show whether it's very
dark, dark, bright and very bright according to some if else statements. We'll measure the light level in %.
Out of a total of 1023 integers, 0 represents 0% and 1023 represents 100%. This calibration process
ensures that the circuit responds accurately to the desired light levels.
Instrumentation and Controls
Applications:
1. Home automation – by using light detector (LDR), we can use Arduino to turn on the lights when
it detects darkness and turn them off when it detects light. This can help save energy and
provide convenience.
2. Security systems - light detectors can be used in security systems to trigger alarms or activate
cameras when there is a sudden change in light intensity. This can help detect intruders or unusual
activities in a specific area.
3. Plant monitoring – light is crucial for the growth of plants. By using a light detector, you can
monitor the amount of light received by your plants and ensure they are getting the optimal
conditions for growth. This can be particularly useful for indoor gardening or greenhouse setups.
4. Weather stations – light detectors can also be used in weather stations to measure the intensity
of sunlight. This information can be used to analyze weather patterns, calculate solar radiation, or
even predict weather conditions.
Materials Needed:
Arduino Uno board
LDR Light dependent resistor
16x2 LCD LCD to IC screen display
Breadboard
Jumper wires
10, 100 kΩ resistor
Relay module 1 channel relay module, 5V, high and low level trigger
Light bulb and wires
1. Connect the I2C backpack of the 16x2 LCD display to the Arduino Uno:
a. SDA (Serial Data) to A4
b. SCL (Serial Clock) to A5
c. GND to GND
d. VCC to 5V
2. Connect the LDR sensor in series with the 10 kΩ resistor between the 5V and GND pins on the
Arduino. Connect the middle point between the resistor and the light sensor to an analog input
pin (e.g., A0) on the Arduino.
3. Write a program (see sample code) to read the digital output of the sensor. The program code
categorizes the light intensity into different levels (dark, dim, light, bright, very bright, etc.) based
on the analog reading. Adjust the threshold values in the if statements to match your specific
sensor’s behavior.
4. Connect the Arduino board USB port to the computer. From the IDE, choose Arduino Uno board
and COM port.
Instrumentation and Controls
5. Upload your program. (Make sure that the required libraries are installed).
6. Observe the display in the LCD panel.
Make a light bulb (or LED) turns on (or off) after the LDR sensor signal reaches a
predetermined level. Example, if the analog value falls below the threshold setting, we consider
it dark, and the relay turns on the light bulb.
Schematic Diagram (Task 2):
Instrumentation and Controls
NOTE: ALWAYS UPLOAD THE SKETCH TO ARDUINO FIRST, THEN DISCONNECT THE ARDUINO AND THEN
CONNECT ALL COMPONENTS!
delay(500);
}
Instrumentation and Controls
NOTE: ALWAYS UPLOAD THE SKETCH TO ARDUINO FIRST, THEN DISCONNECT THE ARDUINO AND THEN
CONNECT ALL COMPONENTS!
int photoValue = 0;
int threshold = 550; // Adjust threshold as needed
void setup()
{
pinMode(ssrPin, OUTPUT);
Serial.begin(115200);
}
void loop()
{
photoValue = analogRead(LDRPin);
Relay module: