Billdefish:
BulldogLowell,
Don't know why I addressed you as Bob. Sorry. Anywho, I'm still a little unclear on the state machine. You may have missed my point though of reducing the amount of if statements and related components.
I want a function like...
Does that make more sense?
Robin2,
Read through the link you provided, thank you.
The only option I can make work correctly(outputs the correct states and data) consists of a ton of if statements and very little interchangeability between boards.
Bill
below is an example of function pointers, in the case that you don't yet understand how to put that together...
if that method works, let us know.
If not, we can always 'point' you in the correct direction 
focus on the loop() function and how simple it is... most of it is to process a button press or entering a char in the serial monitor (which you can do to see how it works).
#include <math.h>
#define NUMBER_OF_ROUTINES 10
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINT(x) Serial.print(x)
#else
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT(x)
#endif
void (*ledFunction[NUMBER_OF_ROUTINES])(void)={ ledFunction0, ledFunction1, ledFunction2, ledFunction3, ledFunction4, ledFunction5, ledFunction6, ledFunction7, ledFunction8, ledFunction9 };
byte ledPin = 13;
byte buttonPin = 2;
byte lastPressed;
byte state = 0;
byte increment = 5;
byte briteness;
unsigned long startTime;
boolean printed = false;
//
void setup()
{
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
//
void loop()
{
int pressed = digitalRead(buttonPin);
if (pressed == LOW)
{
if (pressed != lastPressed)
{
state++;
printed = false;
}
}
lastPressed = pressed;
if (Serial.available())
{
char myChar = Serial.read();
{
state++;
printed = false;
}
}
if (state >= NUMBER_OF_ROUTINES) state = 0;
ledFunction[state]();
}
void ledFunction0()
{
if (!printed)
{
DEBUG_PRINTLN(F("Math Fade"));
printed = true;
}
float val = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
analogWrite(ledPin, val);
}
//
void ledFunction1()
{
if (!printed)
{
DEBUG_PRINTLN(F("Fast Flash"));
printed = true;
}
if (millis() - startTime >= 100UL)
{
digitalWrite(ledPin, !digitalRead(ledPin));
startTime += 100UL;
}
}
//
void ledFunction2()
{
if (!printed)
{
DEBUG_PRINTLN(F("Slow Flash"));
printed = true;
}
if (millis() - startTime >= 500UL)
{
digitalWrite(ledPin, !digitalRead(ledPin));
startTime += 500UL;
}
}
//
void ledFunction3()
{
if (!printed)
{
DEBUG_PRINTLN(F("2.5% Duty Cycle Flash"));
printed = true;
}
unsigned long nowMillis = millis();
if (nowMillis - startTime < 25UL)
{
digitalWrite(ledPin, HIGH);
}
if (nowMillis - startTime < 1000UL)
{
digitalWrite(ledPin, LOW);
}
else
{
startTime += 1000UL;
}
}
//
void ledFunction4()
{
if (!printed)
{
DEBUG_PRINTLN(F("Quick Fade"));
printed = true;
}
if (millis() - startTime >= 10UL)
{
briteness += increment;
if (briteness >= 255 || briteness <= 0) increment = - increment;
analogWrite(ledPin, briteness);
startTime += 10UL;
}
}
//
void ledFunction5()
{
if (!printed)
{
DEBUG_PRINTLN(F("Slow Fade"));
printed = true;
}
if (millis() - startTime >= 35UL)
{
briteness += increment;
if (briteness >= 255 || briteness <= 0) increment = - increment;
analogWrite(ledPin, briteness);
startTime += 35UL;
}
}
//
void ledFunction6()
{
static boolean fadeNow;
if (!printed)
{
DEBUG_PRINTLN(F("Fade Down and Up with Pause"));
printed = true;
}
if (millis() - startTime > 1000UL)
{
fadeNow = true;
briteness = 255;
increment = -5;
}
if (fadeNow)
{
for (int i = 0; i < 2; i++)
{
for (int j = 0; j <= 255; j += 5)
{
analogWrite(ledPin, briteness);
briteness += increment;
delay(25);
}
increment = - increment;
}
fadeNow = false;
}
}
//
void ledFunction7()
{
static boolean fadeNow;
if (!printed)
{
DEBUG_PRINTLN(F("Fade Up then Down with Pause"));
printed = true;
}
if (millis() - startTime > 1000UL)
{
fadeNow = true;
briteness = 0;
increment = 5;
}
if (fadeNow)
{
for (int i = 0; i < 2; i++)
{
for (int j = 0; j <= 255; j += 5)
{
analogWrite(ledPin, briteness);
briteness += increment;
delay(25);
}
increment = - increment;
}
fadeNow = false;
}
}
//
void ledFunction8()
{
if (!printed)
{
DEBUG_PRINTLN(F("Led On"));
printed = true;
}
digitalWrite(ledPin, HIGH);
}
//
void ledFunction9()
{
if (!printed)
{
DEBUG_PRINTLN(F("Led Off"));
printed = true;
}
digitalWrite(ledPin, LOW);
}