       blinkToggle = !blinkToggle;
     }
   }
-  
-  p1Event = p1Button.handle();
-  if (!gameOver && p1Event == BUTTON_SHORT) {
-    lastActivityTime = millis();
-    if (sleeping)
-      return;
-
-    p1Score++;
-    numServes++;
-    showScore();
-    checkForWinner();
-  }
-  
-  if (gameOver && p1Event == BUTTON_LONG) {
-    lastActivityTime = millis();
-    if (sleeping)
-      return;
-
+
+  // Reset the game when requested
+  if (gameOver && requestReset) {
     resetGame();
-    currentServe = 0;
-    numServes = 0;
-    showScore();
-  }
-  
-  p2Event = p2Button.handle();
-  if (!gameOver && p2Event == BUTTON_SHORT) {
-    lastActivityTime = millis();
-    if (sleeping)
-      return;
-
-    p2Score++;
-    numServes++;
-    showScore();
-    checkForWinner();
-  }
-  
-  if (gameOver && p2Event == BUTTON_LONG) {
-    lastActivityTime = millis();
-    if (sleeping)
-      return;
-
-    resetGame();
-    currentServe = 1;
-    numServes = 0;
-    showScore();
-  }
-
+  }
+  
   delay(20);
 }
 

}

// Game Logics
int p1Score = 0;
int p2Score = 0;
int currentServe = 0; // p1 = 0, p2 = 1
int numServes = 0;
int gameOver = 0;
int victoryBlinkCounter = 0;

unsigned long lastActivityTime;

boolean p1Win = false;
boolean p2Win = false;
boolean blinkToggle = true;
boolean sleeping = false;

Button p1Button(P1PIN);
Button p2Button(P2PIN);
VictorySong victorySong(SPEAKERPIN);

void setup()
{
  pinMode(LATCH, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DATA, OUTPUT);

  pinMode(P1LIGHTPIN, OUTPUT);
  pinMode(P2LIGHTPIN, OUTPUT);

  digitalWrite(P1LIGHTPIN, HIGH);
  digitalWrite(P2LIGHTPIN, HIGH);
  
  showScore();
  
  p1Button.init();
  p2Button.init();
  victorySong.init();
  lastActivityTime = millis();
}


void loop()
{
  int p1Event, p2Event;

  if ((millis() - lastActivityTime) > INACTIVEMILLIS) {
    goToSleep();
  } else {
    wakeup();
  }
  
  if (gameOver) {
    victoryBlinkCounter++;


  // Blank p2 score

  // Turn off button lights
  digitalWrite(BUTTONLIGHTPIN, LOW);
}

 void wakeup()
 {
   if (!sleeping)
     return;
   
   sleeping = false;
   
   showScore();
   
   digitalWrite(BUTTONLIGHTPIN, HIGH);
 }


