Basic syntax for using 1 switch to cycle programs

Hello All:

Please forgive me for this noob question. I'm trying to write a simple program to do the following:

Input 1 - tact switch
Output 1 - LED
Analog input 1 - Potentiometer

I'm trying to cycle through 3 different states by pushing the tact switch 3 consecutive times:

State 1 - light off
State 2 - light blinking at frequency determined by potentiometer
State 3 - light solid
....then back to state 1 if button is pushed again.

I've had no trouble establishing the contents of each state but I'm having a tough time getting the cycling portion to work with only button.

Thus far I've tried:
If...else
switch case

I'm grateful for any advice you can provide on program structure.

Thanks!

There are multiple solutuins to such a problem, but a finite state machine would be a good solution.

A FSM could look somethink in the likes of:

/*
PROGRAM NOT TESTED
*/
typedef enum ProgramStates { LED_OFF,  LED_BLINK, LED_ON } ProgramStates;

byte ledPin = 13;
boolean state = false;
byte switchPin = 12;
byte potPin = 2;

ProgramStates programState = LED_OFF;

void transitionToNextState( ){
    switch ( programState ) {
         case LED_OFF: programState = LED_BLINK; break;
         case LED_BLINK: programState = LED_ON; break;
         case LED_ON: programState = LED_OFF; break;
    }
}

void getInput(){
    if (digitalWrite(switchPin)==LOW){ //using pullup
        transitionToNextState();
        delay(50); //dirty debounce
    }
}

void setup(){
    pinMode(ledPin,OUTPUT);
    //pinMode all pins
}

void loop(){
    getInput(); 
    switch( programState ){
        case LED_OFF:
        {
             state = false;
             digitalWrite(ledPin,state);
        }
        break;

        case LED_BLINK:
        { 
             state = !state;
             digitalWrite(ledPin,state);
        }
        break;

        case LED_ON:
        {
             state = true;
             digitalWrite(ledPin,state);
        }
        break;
   }
}