IOT

Interfacing Arduino uno with LDR

In this project, we’re going to use an Arduino to create a simple project that will automatically switch on lights when an LDR sensor detects darkness. During this lesson, we will connect an LDR (Light dependent Resister) to an Arduino board. It is a series of really easy lessons for arduino students, hobbyists, and novices.

Whenever a room gets dark due to a fused bulb or any other factors, a light bulb automatically turns on. This may also be used as an emergency lighting system. When there isn’t enough light in a room, use it to switch on a light automatically.

We utilise a sensor called an LDR to detect the intensity of light or darkness (light dependent resistor). The LDR is a sort of resistor that enables larger voltages (low resistance) to flow through it when there is a high intensity of light and passes a low voltage (high resistance) when it is dark. We may make use of this LDR feature in our DIY Arduino LDR sensor project.

How Does It Work?

In this system, the device detects the amount of light in its surroundings and responds accordingly. An LDR is a light-detection sensor that can be used to detect light. When connected to VCC (5V), the LDR produces an analogue voltage that fluctuates in magnitude in direct proportion to the input light intensity. That is, the higher the light intensity, the higher the associated voltage from the LDR. Because the LDR produces an analogue voltage, it is linked to the Arduino’s analogue input pin.

The Arduino’s built-in ADC (analog-to-digital converter) converts the analogue voltage (ranging from 0 to 5V) into a digital value in the range of 0 to 255. (0-1023). The translated digital values read from the LDR through the Arduino will be in the range of 800-1023, if there is enough light in its environment or on its surface.

After that, we programme the Arduino to activate a relay. Turn on an appliance (light bulb) when the light intensity is low (this can be accomplished by covering the LDR’s surface with any item), that is, when the digital values read are higher than usual.

Components Used:

  • LDR Sensor
  • Arduino Uno
  • Relay Module
  • Bread Board
  • Jumper wires
  • Resistor 10k
  • LED

Arduino Uno:

Arduino Uno is an open-source based on the Microchip ATmega328P developed by Arduino. cc.  It contains 14 digital I/O pins (six of which may be used as PWM outputs), six analogue inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power connector, an ICSP header, and a reset button. It comes with everything you need to support the microcontroller; simply connect it to a computer through USB or power it using an AC-to-DC converter or battery to get started.

LDR Sensor:

LDRs (light dependent resistors), commonly known as photoresistors, are light-sensitive devices. Photoresistors are used to detect the intensity of light, as well as its presence or absence. When there is darkness, the photoresistor’s resistance rises, and when there is enough light, it falls substantially.

There are two terminals on an LDR (light dependent resistor). The signal pin on terminal one should be connected in accordance with the coding. The ground pin is an additional terminal that should be linked to the system’s ground. A light-emitting diode (LED) is a semiconductor device that generates light when an electric current is conducted through it in its most basic form. When the current-carrying particles (known as electrons and holes) collide within the semiconductor material, light is created. Positive and negative terminals are found on leds.

Jumper wires:

These are simple connecting wires that link the ends without the need for soldering. Male wires have connector ends that can be linked to other cables, while female lines have the receiving end.

Resistor:

The resistor protects the sensor and the Arduino board from damage by limiting excessive current flow in any condition. The resistor in this interface circuit has a value of 10k.

Connections:

Arduino LDR Sensor:The first terminal of the LDR sensor should be connected to the Arduino’s analogue pin 0 (A0). Any one of the resistor’s leds should be linked to the second terminal. The Gnd pin on the Arduino should be linked to the other leg of the resistor.

Connections for the leds: The positive pin should be linked to Arduino’s digital pin 5. Any one of the resistor’s leds should be attached to the negative pin. The Arduino’s Gnd should be linked to the other leg of the resistor

Circuit diagram:

Program Code:

const int ledPin = 13;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);

}

void loop() {

int ldr = analogRead(ldrPin);

if (ldr <= 30) {

digitalWrite(ledPin, HIGH);

Serial.print(“Its Night Time, Turn on the LED : “);

Serial.println(ldr);

} else {

digitalWrite(ledPin, LOW);

Serial.print(“Its daytime, Turn off the LED : “);

Serial.println(ldr);

}
Serial.println(ldr);
}
}

Applications:

  • The LDR is used in infrared astronomy.
  • In light failure alarm circuits and used in light meters.
  • LDR used in smoke detectors.
  • Automatic contrast and brightness control in television receivers.
  • used in photosensitive relay
  • used in optical coding.
  • used in street light control circuits.
  • used in camera light meters.
  • used in the security alarm.
  • used as a proximity switch.

Leave a Reply

Your email address will not be published.