LDR Sensor Control With Arduino
Hello friends, Welcome to my SriTu Hobby blog. So far we have described 20 articles through the blog. Each of these articles explains the basics of Arduino components. You can read these previous articles. So let’s go to today’s post. Today we are going to talk about the LDR sensor.
What is an LDR sensor?
It is called a Light Dependent Resistor. It is a resistor. This is also known as a photoresistor. This is a semiconductor device. Depending on the amount of light falling on the sensor surface, the resistance value increases or decreases. It depends on the electron value. The higher the light, the higher the electron value, and the lower the light, the lower the electron value. As the electron value increases, the resistance value decreases as the current is easier to flow. When the electron value decreases, the resistance value increases as the current becomes difficult to flow. We can use this method to create light-sensitive circuits. This sensor is also used for night-active street lamps. We can use this sensor for various projects. It depends on your creativity. Ok, let’s check this sensor activity using a multimeter. Use a multimeter and sensor for this.
Supplies
- Arduino Uno board
- LDR sensor
- LED bulb
- Breadboard
- 180ohm resistor
- 10k resistor
- Jumper wires
Components
Let us identify these components.
Let’s Look at the Code Below
Let’s look at the code below.
For the first time, we have defined the pins we use.
Then, the pin connected to the LED bulb is set to the output pin and the serial monitor is activated. These codes are included in the void setup function.
After that, the sensor value is read and put into the integer variable. The variable name is called “value”.
This code converts the value from 0 – 1024 to 0 – 255. This is because the PWM value ranges from 0 – 255.
Then, using this value, the LED bulb is turned on and off.
With this code, the amount of light in the bulb increases or decreases depending on the amount of light received by the sensor. Look at the code below. This code turns on the LED bulb when the sensor value reaches a certain value or higher. For that, the if condition is used. Please upload and check these two codes separately.
- The complete program of this project
Now, select the board and port. After, click the upload the code
Everything is done.
Have a good day.