 
 // decay function definitions
 int readperiod=3000; // the time over which we take and average readings
+int lastread=0;
 int baseline; // baseline, to be calculated every readperiod
 int currentavg; // average, taken every readperiod, just in case
 int Q = 1000; // "penalty" value, 1 s to start

    analogWrite(vibpin,amp);

    checkpublish("sl");
<<<<<<< Updated upstream
    checkpublish("sd");
=======
>>>>>>> Stashed changes

}

void checkpublish(String command) {

<<<<<<< Updated upstream
  if (command=="serial" || command=="sl") {
    Serial.print(analogvalue);
    Serial.print("    ");


int r=1;

int lastrecord=0;
int recthreshold=1000; // record on sd card every 5 seconds

// if photon:
// SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() {

