const int ledPin1 = 13; //pin at which LED is connected
const int ledPin2 = 12; //pin at which LED is connected
const int ledPin3 = 11; //pin at which LED is connected
const int ldrPin = A0; //pin at which LDR is connected
int threshold = 250;
void setup() {
Serial.begin(9600);
pinMode(ledPin1, OUTPUT); //Make LED pin as output
pinMode(ledPin2, OUTPUT); //Make LED pin as output
pinMode(ledPin3, OUTPUT); //Make LED pin as output
pinMode(ldrPin, INPUT); //Make LDR pin as input
}
void loop()
{
int ldrStatus = analogRead(ldrPin); //saving the analog values received from LDR
Serial.print("ldrStatus : ");
Serial.println(ldrStatus);
if (ldrStatus >= threshold) //set the threshold value below at which the LED will turn on
{ //you can check in the serial monior to get approprite value for your LDR
digitalWrite(ledPin1, HIGH); //Turing LED ON
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
Serial.print("Its DARK, Turn on the LED : ");
Serial.println(ldrStatus);
}
else
{
digitalWrite(ledPin1, LOW); //Turing OFF the LED
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
Serial.print("Its BRIGHT, Turn off the LED : ");
Serial.println(ldrStatus);
}
}