  */
 
 //type 1 for yun 0 for other
-#define YUN 0
+#define YUN 1
 //temp
 #include <OneWire.h>
 //humidity
 #include <DHT.h>
-//ph?
-#include <SoftwareSerial.h>
+//4char
+//#include <SoftwareSerial.h>
 //yun
 #include <Bridge.h>
 #include <Console.h>

#include <YunServer.h>

#define YUN_SERVER_PORT 5678

/* Data Pins*/
#define lightT 3


//TODO: WE need a mushroom Humidity 

// ph helper .. ikr 
double avergearray(int* arr, int number){
  int i;
  int max,min;
  double avg;
  long amount=0;
  if(number<=0){
    Serial.println("Error number for the array to avraging!/n"); //wow who wrote this?
    return 0;
  }
  if(number<5){   //less than 5, calculated directly statistics
    for(i=0;i<number;i++){
      amount+=arr[i];
    }
    avg = amount/number;
    return avg;
  }
  else{
    if(arr[0]<arr[1]){
      min = arr[0];
      max=arr[1];
    }
    else{
      min=arr[1];
      max=arr[0];
    }
    for(i=2;i<number;i++){
      if(arr[i]<min){
        amount+=min;        //arr<min
        min=arr[i];
      }
      else {
        if(arr[i]>max){
          amount+=max;    //arr>max
          max=arr[i];
        }
        else{
          amount+=arr[i]; //min<=arr<=max
        }
      }//if
    }//for
    avg = (double)amount/(number-2);
  }//if
  return avg;
}

////////////////////////  END HELPERs  ///////////////////////////////


