   }
   else {
     // if you couldn't make a connection:
-    Serial.println("connection failed");
+    Serial.println("connection to azure webservice failed");
   }
 }
 

  }
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
}

void loop(){
  val = digitalRead(MKR1000_PINPIR1);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(MKR1000_LED, HIGH);  // turn LED ON
    delay(150);
    
    if (pirState == LOW) {
      // we have just turned on
      azureHttpPost("{deviceId:NeshMKR100Dev1, motion:1}");
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
      digitalWrite(MKR1000_LED, LOW); // turn LED OFF
      delay(300);    
      if (pirState == HIGH){
      // we have just turned off
      azureHttpPost("{deviceId:NeshMKR100Dev1, motion:0}");
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}

  // polling..if pollingInterval has passed
  if (millis() - lastConnectionTime > pollingInterval) {
    digitalWrite(MKR1000_LED, LOW);   
  }
}

