const byte PinLeds [] = { 8, 7, 6 };
const byte PinButs [] = { A2, A3 };


enum { Off = HIGH, On = LOW };

bool b0;
bool b1;

void ledsOff () {
    for (unsigned n = 0; n < sizeof(PinLeds); n++)
        digitalWrite (PinLeds [n], Off);
}

// read buts, read but 1st again in case pressed instant after being read
bool
readButs () {
    b0  = LOW == digitalRead (PinButs [0]);
    b1  = LOW == digitalRead (PinButs [1]);
    b0 |= LOW == digitalRead (PinButs [0]);
    delay (20);     // debounce
    Serial.print ("readButs: ");
    Serial.print (b0);
    Serial.print (" ");
    Serial.println (b1);
    return b0 | b1;
}

void toggleRelay (
    int   relayIdx )
{
    Serial.println (relayIdx);
    digitalWrite (PinLeds [relayIdx], On);
    delay (500);
    ledsOff ();

    while (readButs ())     // wait if button still pressed
        ;
}

void loop ()
{
    readButs ();

    if (b0 && b1) {
        toggleRelay (2);
    }
    else if (b0) {
        toggleRelay (0);
    }
    else if (b1) {
        toggleRelay (1);
    }
}

void setup ()
{
    Serial.begin (9600);
    ledsOff ();
    for (unsigned n = 0; n < sizeof(PinButs); n++) {
        pinMode (PinButs [n], INPUT_PULLUP);
    }

    for (unsigned n = 0; n < sizeof(PinLeds); n++) {
        pinMode (PinLeds [n], OUTPUT);
    }
}