#define LDR A0
#define LED 10
int data;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C Icd(0x27,16,2);
void setup()
{
pinMode(LED, OUTPUT);
Icd.init();
Icd.backlight();
Icd.setCursor(1, 0);
Icd.print("LIGHT SENSOR");
delay(2000);
Icd.clear();
}
void loop()
{
data = analogRead(LDR);
Icd.setCursor(1, 0);
Icd.print("DATA:");
Icd.print(data);
if (data < 900)
{
digitalWrite(LED, 1);
Icd.setCursor(6, 1);
Icd.print("NIGHT");
delay(1000);
Icd.clear();
}
else
{
digitalWrite(LED, 0);
Icd.setCursor(6, 1);
Icd.print("DAY");
delay(1000);
Icd.clear();
}
}