CapSense IC on Arduino - Switching

Hi Guys,
I have a program whereby i control batteries and join and unjoin at certain voltages.
I have added the Self contained capsense IC to my circiut ( it works great ).
I would like to be able to switch between my code and a manual join and unjoin.
I have not added the manual parts to my code yet as i am not sure of the best way to do it.
My idea is to have 3 positions 1 for auto, 1 for on and 1 for off.
I assume x++ wouldbe the best way to do it but have not had much experience with this, I am still new to programming.

My Question is
How do i direct the program to goto certain sections each time the button is pressed ?
I want to step thru 3 parts then after the 3rd is selected the next push would return to 1.
I will attach my code for the automatic portion ( this is the whole program ).
Thanks Guys
BlackSnake

/*BLACKSNAKE SYSTEMS PTY LTD
DUAL BATTERY CONTROLLER WITH SOFTWARE DELAY.
CREATED BY CHRIS COBLEY
PROJECT REV12, 1,SEPTEMBER,2011

THIS PROGRAM MONITORS 2 BATTERIES AND DISPLAYS THE RESULTS ON A
16 X 2 LIQUID CRYSTAL DISPLAY ( BLUE BACKLIGHT WITH WHITE TEXT ).
IF MAIN BATTERY IS ABOVE 13.2 VOLTS & AUX BATTERY IS ABOVE 5 VOLTS
THE TIMER WILL BEGIN. ONCE THE ELAPSED TIME HAS COMPLETED A RELAY
WILL BE TRIGGERED, JOINING THE TWO BATTERIES. 
ONCE THE MAIN BATT FALLS BELOW 12.6 VOLTS IT WILL AUTOMATICALLY
DISCONNECT THE BATTERIES. AS A SAFETY FEATURE SOFTWARE WILL CHECK TO
SEE IF A AUX BATT IS CONNECTED BY LOOKING FOR A MINIMUM OF 5 VOLTS.
MANUAL OVERRIDES ARE PRESENT IN ELECTRONICS FOR CONNECT & DIDSCONNECT.


 LCD CONNECTIONS:
 * LCD RS PIN TO DIGITAL PIN 12
 * LCD ENABLE PIN TO DIGITAL PIN 11
 * LCD D4 PIN TO DIGITAL PIN 5
 * LCD D5 PIN TO DIGITAL PIN 4
 * LCD D6 PIN TO DIGITAL PIN 3
 * LCD D7 PIN TO DIGITAL PIN 2
 * RED TO +5V 
 * BLACK TO GROUND
*/
// FOLLOWING ARE THE LIBRARIES REQUIRED FOR DISPLAY & TIMING.
#include <LiquidCrystal.h>
#include <Elapsed.h>

// INTERFACE PINS FOR LCD LIBRARY.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LINK = LOW;
int LED = 9;    // VARIABLE FOR LED / RELAY OUTPUT.
int PRESSED = false; // VARIABLE FOR TIMING ELEMENT.
int DEPRESSED = false;
int DEACTIVATE = 0;
int ACTIVATE = 0; // VARIABLE FOR TIMING ELEMENT.
#define INTERVAL 30 // LENGTH OF DELAY BEFORE OUTPUT, IN SECONDS
#define INTERVAL2 10 // SECOND INTERVAL FOR OFF DELAY.
Elapsed timer; // THE VARIABLE FOR TIME.

void setup()
{
 
lcd.begin(16, 2); // SETS THE NUMBER OF LINES & CHARACTERS ON THE DISPLAY.
pinMode(LED, OUTPUT); // SETS THE LED AS AN OUTPUT.
}
// CREATE SOME VARIABLES TO STORE DATA.
float MAINVOLT = 0; // VARIABLE FOR MAIN BATTERY VOLTAGE.
float AUXVOLT = 0; // VARIABLE FOR AUX BATTERY VOLTAGE.
float MBINPUT = 0; // VARIABLE FOR ACTUAL ANALOG INPUT.
float ABINPUT = 0; // VARIABLE FOR ACTUAL ANALOG INPUT.


void loop() {     // let's get measurin'

MBINPUT = analogRead(0); // READ ANALOG INPUT 1 AND STORE RESULT IN MBINPUT.
ABINPUT = analogRead(1); // READ ANALOG INPUT 0 AND STORE RESULT IN ABINPUT.
MAINVOLT = (MBINPUT*19.99)/1024; // CONVERTS RAW INPUT DATA INTO MILLIVOLTS.
AUXVOLT = (ABINPUT*19.99)/1024; // CONVERTS RAW INPUT DATA INTO MILLIVOLTS.

lcd.setCursor(0,0);
lcd.print("MAIN BATT:"); // Prints "Main Batt" on LCD Display
lcd.setCursor(12,0);
lcd.print(MAINVOLT,1); // Prints voltage from Sensor 1 (Analog Input 0)
if (AUXVOLT >= 5.0 && LINK == LOW)
{
   lcd.setCursor(0, 1); // Selects line 2 on LCD Display
   lcd.print("AUX BATT:"); // Prints "Aux Batt:" on LCD Display
   lcd.setCursor(9,1);
   lcd.print("   ");
   lcd.setCursor(12,1);
   lcd.print(AUXVOLT,1);
}
if (MAINVOLT >= 13.2 && !PRESSED && ACTIVATE != HIGH) // SETS THE VOLTAGE LEVEL 
// THAT THE RELAY WILL TURN ON AND STARTS THE TIMING.

  {
   DEACTIVATE = LOW;
   ACTIVATE = HIGH;
   PRESSED = true;
   timer.reset(); // RESET THE TIMER.
  }
  
if (PRESSED && timer.intervalMs()>(INTERVAL * 1000) && MAINVOLT >= 13.2) // COMPARES CURRENT MILLIS AND TIMING.
  {
    
   LINK = HIGH;
   PRESSED = false; // SETS PRESSED TO FALSE
   digitalWrite(LED, HIGH); // SETS LED OUTPUT TO HIGH.
  }
  
if (MAINVOLT <= 12.6 && !DEPRESSED && DEACTIVATE != HIGH) // SETS VOLTAGE THAT RELAY WILL DISCONNECT BOTH BATTERIES.
  {
   DEACTIVATE = HIGH;
   DEPRESSED = true;
   LINK = LOW;
   ACTIVATE = LOW;
   timer.reset();
  }
  if (DEPRESSED && timer.intervalMs()>(INTERVAL2 * 1000) && MAINVOLT <= 12.6) // COMPARES CURRENT MILLIS AND TIMING.
  {
   DEPRESSED = false; // SETS PRESSED TO FALSE
   digitalWrite(LED, LOW); // SETS LED OUTPUT TO HIGH.
   lcd.setCursor(10,1);
   lcd.print("  ");
   lcd.setCursor(12,1);
   lcd.print(AUXVOLT,1);
  } 
if (AUXVOLT <= 5.0) // SETS SAFETY BARRIER FOR AUX BATTERY.
  {
   LINK = LOW;
   ACTIVATE = LOW; // SETS ACTIVATE TO LOW.
   digitalWrite(LED, LOW); // SETS LED OUTPUT TO LOW.
   lcd.setCursor(0,1);
   lcd.print(" NO AUX BATTERY ");
  }
if (LINK == HIGH)
 {
  lcd.setCursor(10,1);
  lcd.print("LINKED");
 }

lcd.setCursor(0,0);
lcd.print("MAIN BATT:"); // Prints "Main Batt" on LCD Display
lcd.setCursor(12,0);
lcd.print(MAINVOLT,1); // Prints voltage from Sensor 1 (Analog Input 0)
/*lcd.setCursor(0, 1); // Selects line 2 on LCD Display
 lcd.print("AUX BATT:"); // Prints "Aux Batt:" on LCD Display
*/
lcd.setCursor(0, 0); // Resets LCD display for next loop
delay(50); // 50ms Delay
}
MBINPUT = analogRead(0); // READ ANALOG INPUT 1 AND STORE RESULT IN MBINPUT.

I just love when completely obvious comments are wrong.

MAINVOLT = (MBINPUT*19.99)/1024; // CONVERTS RAW INPUT DATA INTO MILLIVOLTS.

All capital letter names, by convention, are reserved for constants. Constants never appear on the left of an equal statement, except in the declaration statement. The comments look like you are screaming.

Is there some reason you are performing integer division?

My idea is to have 3 positions 1 for auto, 1 for on and 1 for off.

3 positions of what? Do you mean 3 states? Why do you need 1 for off? Manual and auto are all that you need.

I assume x++ wouldbe the best way to do it

To do what? Are you sure that shouldn't be X++?

How do i direct the program to goto certain sections each time the button is pressed ?

Well, goto certainly isn't the right way.

if(state == manual)
{
   // Do whatever manual means
}
else if(state == auto)
{
   // Do whatever auto means
}
else
{
   // Do whatever off means
}

I want to step thru 3 parts then after the 3rd is selected the next push would return to 1.

state++;
if(state > 2)
   state = 0;

Possible states are then 0, 1, or 2.