#include <LiquidCrystal_I2C.h>
  // put your setup code here, to run once:
int red = 13;
int pirpin = 12;
int pirstate = LOW;
int val = 0;
#define ldrpin 7
LiquidCrystal_I2C lcd (0x27, 16, 2);
void setup(){
pinMode(red, OUTPUT);
pinMode(pirpin, INPUT);
pinMode(ldrpin, INPUT);
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Multisensor PIR dan LDR");
delay(1000);
lcd.clear();
}
void loop() {
  // put your main code here, to run repeatedly:
val = digitalRead(pirpin);
if (val == LOW && digitalRead(ldrpin) == LOW){
  digitalWrite(red, LOW);
  lcd.setCursor(0,0);
  lcd.print("Ruangannya Terang");
  if (pirstate == HIGH ){
    lcd.setCursor (0, 1);
    lcd.print("Tidak Ada Gerakan");
  }
}
else{
  if(val==HIGH && digitalRead(ldrpin) == LOW){
    digitalWrite(red, HIGH);
    lcd.setCursor(0,0);
    lcd.print("Ruangannya gelap, nyalakan LED");
    if(pirstate == LOW){
      lcd.setCursor(0,1);
      lcd.print("Ada Gerakan");
      pirstate == HIGH;
    }
  }
}
}