Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Understanding the Light Dependent Resistor (LDR)

Importance and Utility of the Light Dependent Resistor

The Light Dependent Resistor (LDR) is a crucial component in electronic circuits that can detect and respond to changes in light intensity. It is widely used in various applications such as automatic streetlights, security systems, and light-sensitive switches. Understanding the LDR and its functionality is essential for engineers and hobbyists working with Arduino or other microcontrollers.

Project: Building a Light-Sensitive LED Control System

In this project, we will create a simple circuit using an LDR and an Arduino board to control an LED based on the ambient light intensity. The objective is to turn on the LED when it gets dark and turn it off when it gets bright.

List of Components:

  • Arduino Uno board x 1
  • Light Dependent Resistor (LDR) x 1
  • 220-ohm resistor x 1
  • LED x 1
  • Breadboard x 1
  • Jumper wires

Examples:

  1. Circuit Setup:

    • Connect the LDR to the Arduino board as follows:
      • Connect one leg of the LDR to the 5V pin on the Arduino.
      • Connect the other leg of the LDR to the A0 analog input pin on the Arduino.
      • Connect one leg of the 220-ohm resistor to the A0 pin on the Arduino.
      • Connect the other leg of the 220-ohm resistor to the GND pin on the Arduino.
      • Connect the positive leg of the LED to digital pin 13 on the Arduino.
      • Connect the negative leg of the LED to the GND pin on the Arduino.
    • Ensure that the LDR and LED are properly placed on the breadboard.
  2. Code Explanation:

    // Define the pins
    const int ldrPin = A0;
    const int ledPin = 13;
    
    void setup() {
     pinMode(ledPin, OUTPUT); // Set the LED pin as an output
     Serial.begin(9600); // Initialize the serial communication
    }
    
    void loop() {
     int lightIntensity = analogRead(ldrPin); // Read the light intensity value from the LDR
     Serial.println(lightIntensity); // Print the light intensity value to the serial monitor
    
     if (lightIntensity < 500) { // If it is dark
       digitalWrite(ledPin, HIGH); // Turn on the LED
     } else { // If it is bright
       digitalWrite(ledPin, LOW); // Turn off the LED
     }
    
     delay(1000); // Delay for 1 second
    }
    • The code starts by defining the pins for the LDR and LED.
    • In the setup function, the LED pin is set as an output, and the serial communication is initialized.
    • The loop function reads the light intensity value from the LDR using the analogRead function and prints it to the serial monitor.
    • Based on the light intensity value, the code turns on or off the LED using the digitalWrite function.
    • A delay of 1 second is added to avoid rapid switching of the LED.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.