#include <Wire.h>
#include <MPU6050_light.h>


// Create objects. Each sensor is on the "Wire" I2C bus.
MPU6050 mpu=MPU6050(Wire);



const int AD0pin= 27;

const int mpuAddr = 0x68;  // I2C address
const int mpuAddr_not_used = 0x69; // not even used in the code.

unsigned long previousMillis;
const unsigned long interval = 1000;
int inputPin = 4;              
int pirState = LOW;            
int val = 0;    
int Buzz=14;               

#define LDR_PIN 12
void setup() {
  pinMode(inputPin, INPUT);     
  pinMode(LDR_PIN, INPUT);
  pinMode(Buzz, OUTPUT);
  pinMode(18, OUTPUT);
  Serial.begin(9600);
   Wire.begin(); // default pins: SDA=21, SCL=22.
}
void loop(){
    val = digitalRead(inputPin); 
    if (val == HIGH) {   
      digitalWrite(18, HIGH);    
      if (pirState == LOW) {
        Serial.println("Motion detected!");
        pirState = HIGH;
      }
    } else {   
      digitalWrite(18, LOW);    
      if (pirState == HIGH) {
        Serial.println("Motion ended!");
        pirState = LOW;
      }
    } 
    if (digitalRead(LDR_PIN) == LOW) {
    Serial.println("Light");
    tone(Buzz,1200);
    delay(150);
  } else {
    Serial.println("Dark");
    noTone(Buzz);
  }
  delay(1000);
}