const int lamp = 12;
const int ldrPin=A0;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup() {
Serial.begin(9600);
pinMode(lamp , OUTPUT);
lcd.begin();
}
void loop() {
int ldrStatus=analogRead(ldrPin);
delay(500);
if(ldrStatus<=300){
digitalWrite(12,HIGH);
lcd.setCursor(5,0);
lcd.print("OPEN");
delay(500);
lcd.clear();
delay(500);
}
else {
digitalWrite(12,LOW);
lcd.setCursor(5,1);
lcd.print("CLOSE");
delay(500);
lcd.clear();
delay(500);
}
}