LDR With Arduino

In this tutorial, we are going to learn about how to use Light Dependent Resistor with Arduino and we are going to do a small project based on the LDR sensor.

What is LDR?

Light Dependent Resistor or Photoresistor, which is a passive electronic component, basically a resistor that has a resistance that varies depending on the light intensity.

In the dark, a photoresistor can have a resistance as high as several megohms (MΩ), while in the light, a photoresistor can have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds a certain frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band. The resulting free electrons (and their hole partners) conduct electricity, thereby lowering resistance. The resistance range and sensitivity of a photoresistor can substantially differ among dissimilar devices. Moreover, unique photoresistors may react substantially differently to photons within certain wavelength bands.

Video

What we are going to do!

We are going to connect an LED and a Photoresistor(Light Dependent Resistor or LDR) with an Arduino and program it to respond according to the light in the room.

If the room is dark then the LED will turn ON and if the room is bright then the LED will turn OFF.

Hardware Required

ComponentsAmazon.comamazonBanggood.combanggoodAliExpressali expressUtsourceutsource
Arduino UNOcart iconcart iconcart iconcart icon
Photoresistorcart iconcart iconcart icon
LEDcart iconcart iconcart iconcart icon
Resistor(10k,220ohm)cart iconcart iconcart iconcart icon

Circuit

LDR with Arduino UNO
  • Connect the A0 analog pin of Arduino to any pin of the LDR.
  • Connect the other pin of Photoresistor to the 3v of Arduino.
  • Then connect the 10k resistor from GND to A0 of Arduino.
  • Connect the GND of LED to the GND of Arduino via 220 Ohm resistor and
  • Finally, connect the anode of the LED to the 13th pin of Arduino.

Code

  • Upload the above code and open the serial monitor.
  • Now you will be able to see some values are printing in the serial monitor, cover the LDR with your hand or turn off the light in your room.
  • Now the values will be decreasing, note down the current value.
  • Go to the done and change the value of the threshold to the noted value in the previous step.
  • Now upload the code again.
  • Now, whenever the value goes below the threshold value then the LED will turn ON.
  • You can replace the LED with some relay for controlling heavy loads.

To buy electronic components order from UTSOURCE

Leave a Comment

Your email address will not be published. Required fields are marked *