Buttons to start different loops

justjed:
Sounds like a state machine. What should your code do if both buttons are pressed?

Sort of psuedo-code here. Still on my 1st cup of coffee.

int state;

void loop () {
   state = 0;
   if (digitalRead(PIN_A) == HIGH state = state || 1;
   if (digitalRead(PIN_B) == HIGH state = state || 2;

Given you reset state within the loop, you probably should make it a local variable. More importantly, you want the '|' operator and not '||'. The '||' only returns 0 or 1, while you want the state to vary between 0 and 3. I would write it as:

void loop () {
    int state = 0;
    if (digitalRead (PIN_A))
        state |= 1;
    if (digitalRead (PIN_B))
        state |= 2;
    // ...
}

or even, though this is probably harder to read:

void loop () {
    int state = ((digitalRead (PIN_A) ? 1 : 0) | ((digitalRead (PIN_B) ? 2 : 0);
    // ...
}