Help required with output control with timing

Hi,

How do I control a peristaltic pump to drip very slowly using the millis() function?
My peristaltic pump turns on based on a value received from a sensor. But I don't seem to be getting this correct. I made an interval of 2seconds but that only prints the value on the serial monitor every 2seconds.

Any assistance would be appreciated.

my code is as follows:

#define pHUp 13
#define pHDown 2
#define samplingInterval 50
#define printInterval 200
#define ArrayLenth  40    //times of collection
int pHArray[ArrayLenth];   //Store the average value of the sensor feedback
int pHArrayIndex=0;

void setup(void)
{
  pinMode(pHUp,OUTPUT);
  pinMode(pHDown,OUTPUT);
  digitalWrite(pHUp,HIGH);
  digitalWrite(pHDown,HIGH);
  Serial.begin(115200);
}

void loop(void)
{
  static unsigned long samplingTime = millis();
  static unsigned long printTime = millis();
  static float pHValue,voltage;
  if(millis()-samplingTime > samplingInterval)
  {
      pHArray[pHArrayIndex++]=analogRead(SensorPin);
      if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
      voltage = avergearray(pHArray, ArrayLenth)*3.3/1024;
      pHValue = 3.5*voltage+Offset;
      samplingTime=millis();
  }

        if (pHValue <5)
        {
          if(millis() - printTime > printInterval)  
  {
          digitalWrite(pHUp,LOW);
                Serial.print("UP: ");
               printTime=millis();
  }
        }
}

I made an interval of 2seconds but that only prints the value on the serial monitor every 2seconds.

The interval also causes the pin, pHUp, to be set LOW.

What do you really want to have happen? That is, what should happen if pHValue is less than 5?

What pump are you using? How is it powered?

It doesn't look like you have anything to set pHUp HIGH once the PH is OK.