 #define ON 1
 #define OFF 0
 
-//------------------------------------------------------------------
 const int SAMPLES_TO_AVERAGE = 5; // samples for smoothing 1 to 10 seem useful 5 is default
 // increase for smoother waveform (with less resolution - slower!)
 int binOut; // 1 or 0 depending on state of heartbeat



    if (millis() - lastValleyTime > 1800) { // insure reset slower than lowest human HB
      IR_smoothValley =  smooth((float)IR_valley, 0.6, (float)IR_smoothValley);  // smooth valleys
      IR_valley = 0;
      lastValleyTime = millis();
    }


    //Heart Rate Monitor Read
    Wire.beginTransmission(HRAddress);  // transmit to SI1146 Heart Rate Monitor device #96 (0x60)
    Serial.println("Heart Rate Read Attempt");
    readPulseSensor();
    //---> Insert into FRAM

    // Grab temperature measurements and print them.
    float objt = tmp006.readObjTempC();
    objt = objt * (9 / 5) + 32;
    Serial.print("Object Temperature: "); Serial.print(objt);
    Serial.println("*F");
    float diet = tmp006.readDieTempC();
    diet = diet * (9 / 5) + 32;
    Serial.print("Die Temperature: "); Serial.print(diet);
    Serial.println("*F");
    RFduinoBLE.sendByte(0x05);
    delay(75);
    RFduinoBLE.sendFloat(objt);
    delay(75);
    RFduinoBLE.sendByte(0x06);
    delay(75);
    RFduinoBLE.sendFloat(diet);
    delay(75);

    //---> Insert into FRAM

    //Galvanic Skin Response Read
    float gsr = analogRead(4);
    Serial.print("Galvanic Skin Response: "); Serial.println(gsr);
    RFduinoBLE.sendByte(0x07);
    delay(75);
    RFduinoBLE.sendFloat(gsr);
    delay(75);
    //---> Insert into FRAM

    //    // Add Floats together to send in a single BLE.send
    //   char output[4];
    //    //first we add the time stamp (4 bytes)
    //   long objt_long = objt;
    //
    //    for (int j = 0; j < 4; j++){
    //      output[4-j]=(char)(objt_long >> (8*j) & 0xFF);
    //    }
    //    RFduinoBLE.send(objt);

    //Reset State
    state = POLL_SENSORS;
