🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions
























Write a program to interface Light Dependent Resistor (LDR) and display the values read on the Serial monitor after delay of 2 seconds each.

Last Updated : 16 Jul 2025

Solution:

const int ldrpin = A0;  // LDR (Light Dependent Resistor) connected to analog pin A0

void setup(){
    Serial.begin(9600);  // Initialize serial communication at 9600 baud rate
}

void loop(){
    int ldrvalue = analogRead(ldrpin);  // Read the value from the LDR
    Serial.println(ldrvalue);           // Print the LDR value to the serial monitor
    delay(2000);                        // Wait for 2 seconds before taking the next reading
}
Report an error

Meanwhile you can watch this video

Watch Video
Latest Updates