#include <Adafruit_CircuitPlayground.h>

//this functions uses three sensors to determine if something is wrong in the office out of office working hours
int lockOffice() {
  float sound;
  float light;
  float tempC;
  int reason = 0 ;
  // reason 0 is OK 
  //reason 1 is someone turned the light
  //reason 2 is heard a sound 
  //reason 3 is fire alert
   
  if (reason == 0 ) {
    light = CircuitPlayground.lightSensor();
    sound = map(CircuitPlayground.mic.soundPressureLevel(10), 50,70,0,10);
    tempC = CircuitPlayground.temperature();
    Serial.println("-----------------------");
    Serial.println(light);
    Serial.println(sound);
    Serial.println(tempC);
    Serial.println("-----------------------");
    if (light > 20){
      reason = 1;
    }
    if(sound > 8){
      reason = 2;
    }
    if(tempC >= 50 ){
      reason = 3;
    }
    
  }
 return reason; 
  
}
