SHARE
TWEET

selectScore

ChipSkylarkk Jun 24th, 2013 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int selectScore()
  2. {
  3.   lcd.print("Player 1, select");
  4.   lcd.setCursor(0, 1);
  5.   lcd.print("score limit by");
  6.   delay(3000);
  7.   lcd.setCursor(1,0);
  8.   lcd.clear();
  9.   lcd.print("pressing button.");
  10.   delay(3000);
  11.   lcd.setCursor(1,0);
  12.   lcd.clear();
  13.   lcd.print("Player 2");
  14.   lcd.setCursor(0,1);
  15.   lcd.print("confirms by");
  16.   delay(3000);
  17.   lcd.setCursor(1,0);
  18.   lcd.clear();
  19.   lcd.print("pressing their");
  20.   lcd.setCursor(0,1);
  21.   lcd.print("button.");
  22.   delay(3000);
  23.   lcd.clear();
  24.  
  25.   int i;
  26.   int buttonState;
  27.   int lastButtonState;
  28.   int buttonPushCounter=1;
  29.   int confirm=1;
  30.  
  31.   while(confirm==1) //Stay in this loop
  32.   {
  33.     delay(100); //The number will look really dim if you take this out
  34.     lcd.clear();
  35.     lcd.print(buttonPushCounter);
  36.     buttonState = digitalRead(player1);
  37.     confirm = digitalRead(player2);
  38.     if (buttonState != lastButtonState)
  39.     {
  40.       if (buttonState == LOW)
  41.       {
  42.         buttonPushCounter++;
  43.       }
  44.     }
  45.     lastButtonState = buttonState;
  46.     if (buttonPushCounter > 9) //start over at 1
  47.     {
  48.       lcd.clear();
  49.       lcd.print(1);
  50.       buttonPushCounter = 1;
  51.     }
  52.     if (confirm == LOW)
  53.     {
  54.       lcd.clear();
  55.       return buttonPushCounter;
  56.     }
  57.   }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top