 {
     while (true)
     {
-        const unsigned current = sCurrentStep;
+        const unsigned previous = sCurrentStep;
         sCurrentStep = (sCurrentStep + 1) & 0x7;
-        digitalWrite(sPins[current],        LOW);
-        digitalWrite(sPins[sCurrentStep],   HIGH);
+        updatePins(previous);
         if (yield(1000))
         {
             reset();

#include <Bounce.h>

// -----------------------------------------------------------------------------
// Hardware Mapping

static const byte sPins[8] = 
{
    0, 1, 2, 3, 4, 5, 6, 7
};

static const byte sPinMode = 14; // A0
static const byte sPinIncr = 15; // A1
static const byte sPinDecr = 16; // A2

static const unsigned long sDebouncingTime = 10; // ms
Bounce sModeButton(sPinMode, sDebouncingTime);
Bounce sIncrButton(sPinIncr, sDebouncingTime);
Bounce sDecrButton(sPinDecr, sDebouncingTime);

// -----------------------------------------------------------------------------



void setup()
{
    sModeButton.init();
    sIncrButton.init();
    sDecrButton.init();
    pinMode(sGndPin, OUTPUT); // GND reference

    for (byte i = 0; i < 8; ++i)
    {
        pinMode(sOutputPins[i], OUTPUT);
    }
    Serial.begin(115200);
    while (!Serial);
    Serial.print("Ready. Running mode: ");
    Serial.println(sRunningMode ? "manual" : "automatic");
}

void loop()
