int LDR = A2; // LDR define
int LDR_V = 0; // holds value of LDR
void setup() {
pinMode(LDR, INPUT); // LDR singal into board
Serial.begin(9600); // start serial communication
}
void loop() {
LDR_V = analogRead(LDR);
if (LDR_V < 490)
{
Serial.print("Ambient Light level is: ");
Serial.println(LDR_V);
Serial.println("the light is... ON!");
delay (2000);
}
else
{
Serial.print("Ambient Light level is: ");
Serial.println(LDR_V);
Serial.println("the light is... OFF!");
delay (2000);
}
}