   int pushButtonState = HIGH;
   if(pushButtonState == LOW) {
     // button was pressed, connect for an immediate readout
+    Particle.connect();
+    // turn off the LED in case it was on
+    digitalWrite(D7, LOW);
     buttonPressed = true;
     photonState = PHOTON_CONNECTING;
-    Particle.connect();
     return;
   }
   else {

 ******************************************************************************/

int photoPin = A5;           // photoresistor pin
int powerPin = A0;
int readoutTimeIntervalMins = 1;   // perform a readout every given minutes

const int PHOTON_OFFLINE = 0;
const int PHOTON_CONNECTING = 1;

void setup() {
  pinMode(photoPin, INPUT);     // prepare the photoresistor
  pinMode(powerPin, OUTPUT);
  pinMode(D7, OUTPUT);       // the integrated LED signals readout errors
  digitalWrite(powerPin, HIGH);
}

