title: Arduino Loop Confusion
body: <p>I'm creating an auto watering system for some plants. I am using a motor to control them, and soil sensors to tell when they need water. But I'm having trouble both understanding how I should be approaching this and secondly why my code isn't working. My problem is that the while loop is never initialized, and so the motor never stops I can tell this by my serial monitor.</p>
  
  <pre><code>      if(sensorVal1 &lt;= thresholdDown1){
  Serial.println("Plant Group 1 is Dry!");
  Serial.println(sensorVal1);
  Serial.println("Watering");
  digitalWrite(in1, LOW); //LEFT
  digitalWrite(in2, HIGH);
  analogWrite(enA, 255);
  
  delay(6250);
  
  
  startTime = millis();
  while(sensorVal1 &lt;= thresholdDown1){
    Serial.println("Stopping");
      digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  
        if(sensorVal1 &gt;= thresholdUp1){
       break;
     }
  }
  
  
  
        totalTime = millis() - startTime;
        digitalWrite(in1, HIGH); //RIGHT
        digitalWrite(in2, LOW);
        delay(500);
        digitalWrite(in1, LOW); //OFF
        digitalWrite(in2, LOW);
        delay(totalTime);
        digitalWrite(in1, HIGH);
        digitalWrite(in2, LOW);
        delay(500);
        digitalWrite(in1, LOW);
        digitalWrite(in2, LOW);
        delay(totalTime);    
        digitalWrite(in1, HIGH);
        digitalWrite(in2, LOW);
        delay(3000);
        digitalWrite(in1, LOW);
        digitalWrite(in2, LOW);
  
  
        }
  </code></pre>