const int pirPin = 2;  // Pin sensor gerak PIR
const int ldrPin = A0;  // Pin sensor cahaya LDR
const int ledPin = 13;  // Pin output LED

int motionDetected = 0;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  motionDetected = digitalRead(pirPin);
  int lightLevel = analogRead(ldrPin);
  Serial.print("Light Level: ");
  Serial.println(lightLevel);
  
  if (motionDetected == HIGH && lightLevel < 500) {
    digitalWrite(ledPin, HIGH);
    Serial.println("Motion detected. Turning on the light.");
  } else {
    digitalWrite(ledPin, LOW);
    Serial.println("No motion or sufficient light. Turning off the light.");
  }
  delay(1000);
}