#include <LiquidCrystal_I2C.h>
#define ldr 34
#define led1 2
#define led2 4
#define led3 5
#define led4 18

LiquidCrystal_I2C mylcd(0x27,16,2);


int x,i=0;
void setup(){
  Serial.begin(115200);
  pinMode(ldr, INPUT);
  pinMode(led1, OUTPUT); 
  pinMode(led2, OUTPUT); 
  pinMode(led3, OUTPUT); 
  pinMode(led4, OUTPUT);
  digitalWrite(led1,LOW);
  digitalWrite(led2,LOW);
  digitalWrite(led3,LOW);
  digitalWrite(led4,LOW);
  mylcd.init();
  mylcd.backlight(); 
  
 }
void loop(){
  x = analogRead(ldr);
  Serial.println(x);
  delay(1000);
  if(i != x){
    mylcd.clear();
    mylcd.setCursor(0,0); mylcd.print("Value =");
    mylcd.setCursor(7,0); mylcd.print(x);

    if(x <=2000){
      digitalWrite(led1, HIGH);
      delay(500);
      digitalWrite(led2, HIGH);
      delay(500);
      digitalWrite(led3, HIGH);
      delay(500);
      digitalWrite(led4, HIGH);
      delay(500);
    }else{
      digitalWrite(led1,LOW);
      delay(500);
      digitalWrite(led2,LOW);
      delay(500);
      digitalWrite(led3,LOW);
      delay(500);
      digitalWrite(led4,LOW);
      delay(500);
    }
  
    delay(500);
  }i = x ;
  
 }