IF Statment

Hi,
I think this might be easy but I realy need help with it. In my code, I set a motor to run as soon as the value of the anlog pin goes below a certain value. however, the motor causes some vibration that cause the analog pin reading to fluctuate. I want the code to stop checking the analog pin when the condition is statified once.

int PressurePin = A1;



void setup() {
 Serial.begin(9600);
}

void loop() {
 delay(100);
 pressure=analogRead(PressurePin);

  Serial.print(pressure);
  if(pressure < 100)
{
 // rest ofthe code
}
}

Stop checking forever? Also does the motor continue to run forever?

Yes and the motor should continue to run.

 if(pressure < 100 && firstTime == true)

or

int PressurePin = A1;

void setup()
{
  Serial.begin(9600);
  while (pressure >= 100)
  {
    delay(100);
    pressure = analogRead(PressurePin);
    Serial.print(pressure);
  }
  // rest ofthe code
}

void loop() {}

alternatively, don't even do the analog read in the loop if the condition has been met:

if(!condition)
  pressure=analogRead(PressurePin);

Thaks alot for the help. very much apreatiated!