Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
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:
Examples:
Circuit Setup:
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
}