const int LEDpin = 12;  
const int photoPIN = A0;  
const int temperature = A1;
const int pirpin =6;
int pirState = LOW;
int value =0;

void setup() {  
  // initializing the serial communication:  
  Serial.begin(9600);  
  pinMode(photoPIN, INPUT);  
  pinMode(LEDpin, OUTPUT);  
  pinMode(pirpin, INPUT);
  pinMode(5, OUTPUT);
  pinMode(11, OUTPUT);
}  
void loop() {  
  // read the sensor:  
  int sensorStatus = analogRead(photoPIN);  
   // now, it will check the reading or status of the sensor is < 200  
  // if it is, LED will be HIGH  
  if (sensorStatus <200)  
  {  
    digitalWrite(LEDpin, HIGH); // LED is ON  
    Serial.println(" light is ON, status of sensor is DARK");  
    delay (1000);
  }  
  else  
  {  
    digitalWrite(LEDpin, LOW);  
    Serial.println("room is dark so light  is off");  
    delay (1000);
  }  
  int Temp = analogRead(temperature);  
  float volts = (Temp / 965.0) * 5;  
  float celcius = (volts - 0.5) * 100;  
  float fahrenheit = (celcius * 9 / 5 + 32);  
  Serial.print("the temperatre is  ");
  Serial.println( celcius);  
  delay(1000);

  if (celcius>40)
  {
    digitalWrite(11, HIGH);
    Serial.println("fan is on ");
  }
  else 
  
  {
    digitalWrite(11, LOW);
    Serial.println ("low temperature so fan off ");

  }
  value =digitalRead(pirpin);
  
  if (value ==HIGH) 
  {
            // check if the input is HIGH
    digitalWrite(5, HIGH);  // turn LED ON
    
      // we have just turned on
    Serial.println("Motion detected!, someone is near the door ");
     
    
    }
  else {
    digitalWrite(5, LOW);
    Serial.println("NO MOTION DETECTED ");
     // turn LED OFF
    }
    
}