Need Help With Vacuum Pressure Controller!

I'm currently working on a vacuum pressure controller for another project I have in the works. Basically I'm using a 12v vacuum pump connected to a motorshield with a vacuum pressure sensor that output an analog signal between 0 and 1023. The sensor itself is rated for a vacuum pressure range between 0 and 16 in/hg. I know I could probably optimize the code and get the controller to work a bit more smoothly, but I'm still pretty new to all this, so all things considered, I'm surprised I've come this far. What the controller is supposed to do is vary the vacuum pressure of the pump based on predefined pressures stored in an array. I need it to modify the pump pressure based on the predefined pressures at predefined intervals. So far, that works. What I'm having trouble with is that I can't get it to repeat the entire sketch more than twice. My suspicion is that the arduino is running out of memory, or that I'm using the wrong types of variable. My suspicion is that I may need to implement a timer library, which I did try at one point, with little to no success. After it cycles through all the variables a second time, it will either hold the last pressure in the array, or it will randomly kick the pump on and off. My hope is that maybe someone can take a look at my code and tell me where I went wrong, or if I do need to add a timer library of some kind, possibly recommend a simple one, and possibly get me started in the right direction on how to implement it. Thanks in advance guys!

const int analogInPin = A0; //pressure sensor pin assignment
const int pwmPin = 3; //pump speed control pin assignment
const int dirPin = 12; //controls pump direction 

//sets the vaccuum pressure for each pump cycle
const int pumpPressure[] = {
  5, 10, 5, 10, 5, 10, 5, 10 };
//sets the duration of each pump cycle (in seconds)
long unsigned interval[] = {
  10, 5, 10, 5, 10, 5, 10, 5 };
unsigned long startTime = millis();

unsigned long currentInterval = 0;
int lastValue = 0;
int sensorValue = 0;
int outputValue = 0;
int pumpSpeed = 100;
int cycleCount = 0;
int sensorMap = 0;
int totalCycleCount = 1;

void setup() {
  pinMode(dirPin, OUTPUT);
  Serial.begin(9600); 
  digitalWrite(dirPin, HIGH);
  sensorMap = analogRead(analogInPin); //calibrates the pressure sensor
  analogWrite(pwmPin, pumpSpeed); //starts the pump at the predetermined speed
}

void loop() { 
    for(int a = 0; a < 8; a++) {
        cycleCount = a;
        currentInterval = (currentInterval + (interval[a] * 1000));
        while(millis() - startTime < currentInterval)
        {     
          pressureSensor();
          pressureRegulate();
          pressureSerial();
          if(a == 8) {
            a = 0;
          }
        }
        }
      }

void pressureSensor() {   //reads the pressure sensor and then maps it to a value between 0 and 16 in/hg
    sensorValue = analogRead(analogInPin);            
    outputValue = map(sensorValue, sensorMap, 0, 0, 16);
    outputValue = constrain(outputValue, 0, 16);
    lastValue = outputValue;
}

void pressureRegulate() {  //adjusts the pump speed based on the desired pressure for that cycle
    if(lastValue == pumpPressure[cycleCount]) {
      analogWrite(pwmPin, pumpSpeed);
    }
    if(lastValue > pumpPressure[cycleCount]) {
      pumpSpeed--;
      pumpSpeed = constrain (pumpSpeed, 0, 255);
      analogWrite(pwmPin, pumpSpeed);
    }
    if(lastValue < pumpPressure[cycleCount]) {
      pumpSpeed++;
      pumpSpeed = constrain (pumpSpeed, 0, 255);
      analogWrite(pwmPin, pumpSpeed);
    }
}


void pressureSerial() {  //outputs the desired pressure and actual pressure to serial monitor
    Serial.print("set pressure = " );                       
    Serial.print(pumpPressure[cycleCount]);      
    Serial.print("\t pressure = ");      
    Serial.println(output value);
}
const int pumpPressure[] = {

No need to use an int array to store byte sized values.

long unsigned interval[] = {

No need to use a long array to store byte sized values.

My suspicion is that the arduino is running out of memory

I don't see that. There is some unnecessary memory utilization happening, but not that much.

        currentInterval = (currentInterval + (interval[a] * 1000));
        while(millis() - startTime < currentInterval)

This is NOT the way to use millis(). You should record the last time an event occurred (a cycle started), not the next time an event should occur. That is, update startTime, rather than continually incrementing currentInterval.

After it cycles through all the variables a second time, it will either hold the last pressure in the array, or it will randomly kick the pump on and off.

What does your serial output look like?

Thank you for the reply! If i use different values for the pressures to tell at what point in the cycle it is (lets say the last number in the array is 4), cycle all the way through twice, and when it reaches 4, the second time, it stops rotating through the various pressures and timings and just sits on 4, and if I vary the pressure in the line, the sensor will only spit out the last value it read before the program stalled.

the sensor will only spit out the last value it read

The sensor is not spitting out a value. The Arduino is outputting a value that it read from a sensor.

I think that you need to add more Serial.print() statements, to see where the program is getting hung.

It wouldn't hurt to evaluate how much free memory you have.
http://playground.arduino.cc/Code/AvailableMemory