   static long lasttime;
   byte index;
   if (millis() < lasttime) {
-     lasttime = millis(); // we wrapped around, lets just try again
+     lasttime = millis();
   }
 
+  // Wait DEBOUNCE time
   if ((lasttime + DEBOUNCE) > millis()) {
-    return; // not enough time has passed to debounce
+    return;
   }
-  // ok we have waited DEBOUNCE milliseconds, lets reset the timer
+  // reset the timer
   lasttime = millis();
 
   for (index = 0; index < NUMBUTTONS; index++) {
-    /*justpressed[index] = 0;       // when we start, we clear out the "just" indicators
-    justreleased[index] = 0;*/
-
-    currentstate[index] = digitalRead(buttons[index]);   // read the button
+    currentstate[index] = digitalRead(buttons[index]);
     if (currentstate[index] == previousstate[index]) {
-      pressed[index] = !currentstate[index];  // remember, digital HIGH means NOT pressed
+      pressed[index] = !currentstate[index];
     }
-    //Serial.println(pressed[index], DEC);
-    previousstate[index] = currentstate[index];   // keep a running tally of the buttons
+    previousstate[index] = currentstate[index];
   }
 }
 

  // pin13 LED
  pinMode(13, OUTPUT);

  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    digitalWrite(buttons[i], HIGH);

#define DEBOUNCE 10  // button debouncer 5+ ms

byte buttons[] = {3, 4, 5}; // D2-D12
String buttonNames[] = {"pb1", "pb2", "pb3"};
#define NUMBUTTONS sizeof(buttons)

byte potmeters[] = {18}; // A0-14, A5-19 6

String potmeterNames[] = {"pot1"};
#define NUMPOTMETERS sizeof(potmeters)

// pressed buttons
byte pressed[NUMBUTTONS];

void setup() {
