const int GSR = A0;
int threshold = 0;
int sensorValue;

void setup() {
  long sum=0;
  Serial.begin(9600);
  delay(1000);

  for(int i=0;i<500;i++)
  {
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold =");
   Serial.println(threshold);  
}

void loop() {
  int temp;
  sensorValue=analogRead(GSR);
  Serial.print("SensorValue=");
  Serial.println(sensorValue);
  //Serial.print("\n");
  temp = threshold - sensorValue;
  if(abs(temp)>60)
  {
    sensorValue=analogRead(GSR);
    temp = threshold - sensorValue;
    if(abs(temp)>60){
     //Bean.setLed(0,0,255);
     Serial.println("Emotion Changes Detected!");
     delay(3000);
     //Bean.setLed(0,255,0);
     delay(1000);
    }
  }
  Bean.sleep(10000);
}