Betting Station 4a

Video #1

Betting Station 4b

Video #2

#include 
 
LiquidCrystal lcd(12, 13, 11, 10, 9, 8);
 
byte dec_digits[] = { 0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b10010010,0b10000011,0b11111000,0b10000000,0b10011000 };
 
 
// button tests
boolean h12 = false;
boolean h13 = false;
boolean h14 = false;
boolean h15 = false;
boolean h23 = false;
 
boolean h24 = false;
boolean h25 = false;
boolean h34 = false;
boolean h35 = false;
boolean h45 = false;
 
 
// odds on horse combination
int h12bet = 0;
int h13bet = 0;
int h14bet = 0;
int h15bet = 0;
int h23bet = 0;
int h24bet = 0;
int h25bet = 0;
int h34bet = 0;
int h35bet = 0;
int h45bet = 0;
 
boolean coinout = false;
 
int credits = 0;
 
// bets on horse combination
int bet12 = 0;
int bet13 = 0;
int bet14 = 0;
int bet15 = 0;
int bet23 = 0;
int bet24 = 0;
int bet25 = 0;
int bet34 = 0;
int bet35 = 0;
int bet45 = 0;
 
long lastrace = 0;
long x = 0;
long y = 0;
 
boolean coinin = false;
 
void setup() 
{  
  pinMode(22, OUTPUT);
  pinMode(23, OUTPUT);
  pinMode(24, OUTPUT);
 
  pinMode(25, OUTPUT);
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
   
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
 
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
 
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
 
  pinMode(37, OUTPUT);
  pinMode(38, OUTPUT);
  pinMode(39, OUTPUT);
 
  pinMode(40, OUTPUT);
  pinMode(41, OUTPUT);
  pinMode(42, OUTPUT);
 
  pinMode(43, OUTPUT);
  pinMode(44, OUTPUT);
  pinMode(45, OUTPUT);
 
  pinMode(46, OUTPUT);
  pinMode(47, OUTPUT);
  pinMode(48, OUTPUT);
 
  pinMode(49, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(51, OUTPUT);
 
  pinMode(6, INPUT);
  pinMode(5, INPUT);
  pinMode(4, INPUT);
  pinMode(3, INPUT);
  pinMode(2, INPUT);
 
  pinMode(14, INPUT);
  pinMode(15, INPUT);
  pinMode(16, INPUT);
  pinMode(17, INPUT);
  pinMode(52, INPUT);
   
  pinMode(7, INPUT);     // signal from countdown clock
  pinMode(53, INPUT);    // cashout button
  pinMode(54, OUTPUT);   // cashout signal to turn on hopper
  pinMode(21, INPUT);    // coin in break beam
  pinMode(20, INPUT);    // cashout sensor
   
  digitalWrite(54, LOW);
   
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Derby Time");
  lcd.setCursor(0,4);
  lcd.print("Credits = ");
  lcd.setCursor(10,2);
  lcd.print(credits);
   
  clearscreen();
   
  Serial.begin(9600);
}
 
 
 
void clearscreen()
{
      digitalWrite(23, LOW);
      shiftOut(22, 24, MSBFIRST, dec_digits[0]); 
      digitalWrite(23, HIGH);
       
      digitalWrite(26, LOW);
      shiftOut(25, 27, MSBFIRST, dec_digits[0]); 
      digitalWrite(26, HIGH);
   
      digitalWrite(29, LOW);
      shiftOut(28, 30, MSBFIRST, dec_digits[0]); 
      digitalWrite(29, HIGH);
   
      digitalWrite(32, LOW);
      shiftOut(31, 33, MSBFIRST, dec_digits[0]); 
      digitalWrite(32, HIGH);
   
      digitalWrite(35, LOW);
      shiftOut(34, 36, MSBFIRST, dec_digits[0]); 
      digitalWrite(35, HIGH);
   
      digitalWrite(38, LOW);
      shiftOut(37, 39, MSBFIRST, dec_digits[0]); 
      digitalWrite(38, HIGH);
       
      digitalWrite(41, LOW);
      shiftOut(40, 42, MSBFIRST, dec_digits[0]); 
      digitalWrite(41, HIGH);
   
      digitalWrite(44, LOW);
      shiftOut(43, 45, MSBFIRST, dec_digits[0]); 
      digitalWrite(44, HIGH);
   
      digitalWrite(47, LOW);
      shiftOut(46, 48, MSBFIRST, dec_digits[0]); 
      digitalWrite(47, HIGH);
   
      digitalWrite(50, LOW);
      shiftOut(49, 51, MSBFIRST, dec_digits[0]); 
      digitalWrite(50, HIGH);
 
      bet12 = 0;
      bet13 = 0;
      bet14 = 0;
      bet15 = 0;
      bet23 = 0;
       
      bet24 = 0;
      bet25 = 0;
      bet34 = 0;
      bet35 = 0;
      bet45 = 0;
}
 
 
void loop() 
{
  // credit accept test while 7 is low
  if (digitalRead(21) == HIGH && coinin == true)
  {
    coinin = false;
  }
   
  if (digitalRead(21) == LOW && coinin == false)
  {
    credits++;
    coinin = true;
    lcd.setCursor(0,0);
    lcd.print("Credit Accepted");
    lcd.setCursor(0,2);
    lcd.print("Credits = ");
    lcd.print(credits);
    lcd.setCursor(10,2);
  }
   
  // get race information
  if (Serial.available() > 0 && Serial.available() != lastrace)
  {
    x = Serial.parseInt();
    lastrace = x;
     
    // get digit 5 for last race
     
    y = int(x * .1); // 12345 = 1234.5
    y = y * 10; // 12340
    y = x - y;  //12345 - 12340 = 5
     
    // pay out for last race
     
    if (y == 0)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-2 Winner ");
      lcd.print(h12bet * bet12);
      lcd.setCursor(0,2);
      credits = credits + (h12bet * bet12);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    }  
 
    else if (y == 1)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-3 Winner ");
      lcd.print(h13bet * bet13);
      lcd.setCursor(0,2);
      credits = credits + (h13bet * bet13);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 2)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-4 Winner ");
      lcd.print(h14bet * bet14);
      lcd.setCursor(0,2);
      credits = credits + (h12bet * bet12);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 3)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-5 Winner ");
      lcd.print(h15bet * bet15);
      lcd.setCursor(0,2);
      credits = credits + (h15bet * bet15);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 4)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-3 Winner ");
      lcd.print(h23bet * bet23);
      lcd.setCursor(0,2);
      credits = credits + (h23bet * bet23);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 5)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-4 Winner ");
      lcd.print(h24bet * bet24);
      lcd.setCursor(0,2);
      credits = credits + (h24bet * bet24);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 6)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-5 Winner ");
      lcd.print(h25bet * bet25);
      lcd.setCursor(0,2);
      credits = credits + (h25bet * bet25);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 7)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("3-4 Winner ");
      lcd.print(h34bet * bet34);
      lcd.setCursor(0,2);
      credits = credits + (h34bet * bet34);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 8)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("3-5 Winner ");
      lcd.print(h35bet * bet35);
      lcd.setCursor(0,2);
      credits = credits + (h35bet * bet35);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    }     
     
    else if (y == 9)
    {
 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("4-5 Winner ");
      lcd.print(h45bet * bet45);
      lcd.setCursor(0,2);
      credits = credits + (h45bet * bet45);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
       
    int nextraceodds = int(x * .001);  // 12345 = 12
     
    switch(nextraceodds)
        {
          case 10:
            h12bet = 14;
            h13bet = 9;
            h14bet = 39;
            h15bet = 5;
            h23bet = 11;
            h24bet = 47;
            h25bet = 6;
            h34bet = 23;
            h35bet = 3;
            h45bet = 12;
          break;
     
          case 11:
            h12bet = 9;
            h13bet = 21;
            h14bet = 11;
            h15bet = 36;
            h23bet = 6;
            h24bet = 3;
            h25bet = 10;
            h34bet = 7;
            h35bet = 23;
            h45bet = 12;
          break;
           
          case 12:
            h12bet = 19;
            h13bet = 3;
            h14bet = 6;
            h15bet = 25;
            h23bet = 9;
            h24bet = 18;
            h25bet = 76;
            h34bet = 4;
            h35bet = 17;
            h45bet = 34;
          break;
           
          case 13:
            h12bet = 10;
            h13bet = 7;
            h14bet = 6;
            h15bet = 4;
            h23bet = 23;
            h24bet = 20;
            h25bet = 13;
            h34bet = 14;
            h35bet = 9;
            h45bet = 8;
          break;
           
          case 14:
            h12bet = 2;
            h13bet = 34;
            h14bet = 8;
            h15bet = 5;
            h23bet = 49;
            h24bet = 12;
            h25bet = 7;
            h34bet = 200;
            h35bet = 119;
            h45bet = 29;
          break;
           
          case 15:
            h12bet = 95;
            h13bet = 4;
            h14bet = 9;
            h15bet = 37;
            h23bet = 21;
            h24bet = 49;
            h25bet = 200;
            h34bet = 2;
            h35bet = 8;
            h45bet = 19;
          break;
           
          case 16:
            h12bet = 59;
            h13bet = 5;
            h14bet = 23;
            h15bet = 18;
            h23bet = 9;
            h24bet = 42;
            h25bet = 33;
            h34bet = 4;
            h35bet = 3;
            h45bet = 14;
          break;
           
          case 17:
            h12bet = 32;
            h13bet = 44;
            h14bet = 109;
            h15bet = 25;
            h23bet = 5;
            h24bet = 12;
            h25bet = 3;
            h34bet = 17;
            h35bet = 4;
            h45bet = 10;
          break;
           
          case 18:
            h12bet = 4;
            h13bet = 8;
            h14bet = 13;
            h15bet = 5;
            h23bet = 10;
            h24bet = 16;
            h25bet = 6;
            h34bet = 33;
            h35bet = 12;
            h45bet = 20;
          break;
           
          case 19:
            h12bet = 2;
            h13bet = 7;
            h14bet = 5;
            h15bet = 8;
            h23bet = 15;
            h24bet = 11;
            h25bet = 17;
            h34bet = 38;
            h35bet = 61;
            h45bet = 43;
          break;
     
          case 20:
            h12bet = 38;
            h13bet = 2;
            h14bet = 7;
            h15bet = 24;
            h23bet = 16;
            h24bet = 60;
            h25bet = 200;
            h34bet = 3;
            h35bet = 10;
            h45bet = 37;
          break;
           
          case 21:
            h12bet = 8;
            h13bet = 161;
            h14bet = 12;
            h15bet = 24;
            h23bet = 26;
            h24bet = 2;
            h25bet = 4;
            h34bet = 40;
            h35bet = 80;
            h45bet = 6;
          break;
           
          case 22:
            h12bet = 6;
            h13bet = 12;
            h14bet = 3;
            h15bet = 36;
            h23bet = 16;
            h24bet = 4;
            h25bet = 49;
            h34bet = 8;
            h35bet = 11;
            h45bet = 24;
          break;
           
          case 23:
            h12bet = 8;
            h13bet = 29;
            h14bet = 200;
            h15bet = 9;
            h23bet = 6;
            h24bet = 42;
            h25bet = 2;
            h34bet = 159;
            h35bet = 7;
            h45bet = 47;
          break;
           
          case 24:
            h12bet = 2;
            h13bet = 47;
            h14bet = 108;
            h15bet = 18;
            h23bet = 17;
            h24bet = 6;
            h25bet = 3;
            h34bet = 20;
            h35bet = 16;
            h45bet = 19;
          break;
     
          case 25:
            h12bet = 8;
            h13bet = 43;
            h14bet = 108;
            h15bet = 18;
            h23bet = 17;
            h24bet = 6;
            h25bet = 3;
            h34bet = 20;
            h35bet = 16;
            h45bet = 19;
          break;
           
          case 26:
            h12bet = 2;
            h13bet = 8;
            h14bet = 4;
            h15bet = 15;
            h23bet = 14;
            h24bet = 7;
            h25bet = 26;
            h34bet = 29;
            h35bet = 107;
            h45bet = 88;
          break;
           
          case 27:
            h12bet = 5;
            h13bet = 7;
            h14bet = 28;
            h15bet = 14;
            h23bet = 3;
            h24bet = 12;
            h25bet = 6;
            h34bet = 16;
            h35bet = 8;
            h45bet = 33;
          break;
     
          case 28:
            h12bet = 3;
            h13bet = 19;
            h14bet = 2;
            h15bet = 21;
            h23bet = 38;
            h24bet = 4;
            h25bet = 48;
            h34bet = 9;
            h35bet = 99;
            h45bet = 24;
          break;
     
          case 29:
            h12bet = 27;
            h13bet = 9;
            h14bet = 136;
            h15bet = 13;
            h23bet = 4;
            h24bet = 61;
            h25bet = 6;
            h34bet = 20;
            h35bet = 2;
            h45bet = 3;
          break;
     
          case 30:
            h12bet = 2;
            h13bet = 7;
            h14bet = 63;
            h15bet = 12;
            h23bet = 3;
            h24bet = 26;
            h25bet = 5;
            h34bet = 21;
            h35bet = 4;
            h45bet = 36;
          break;
     
          case 31:
            h12bet = 11;
            h13bet = 14;
            h14bet = 6;
            h15bet = 43;
            h23bet = 7;
            h24bet = 3;
            h25bet = 21;
            h34bet = 4;
            h35bet = 28;
            h45bet = 12;
          break;
     
          case 32:
            h12bet = 8;
            h13bet = 86;
            h14bet = 18;
            h15bet = 17;
            h23bet = 19;
            h24bet = 3;
            h25bet = 4;
            h34bet = 30;
            h35bet = 40;
            h45bet = 6;
          break;
     
          case 33:
            h12bet = 14;
            h13bet = 29;
            h14bet = 6;
            h15bet = 109;
            h23bet = 9;
            h24bet = 2;
            h25bet = 34;
            h34bet = 4;
            h35bet = 70;
            h45bet = 15;
          break;
     
          case 34:
            h12bet = 5;
            h13bet = 9;
            h14bet = 17;
            h15bet = 16;
            h23bet = 4;
            h24bet = 8;
            h25bet = 7;
            h34bet = 14;
            h35bet = 13;
            h45bet = 25;
          break;
        }
     // set 7 segment leds back to 0   
      
     clearscreen();
  }
         
// test for cashout button pressed while 7 is low
 
            if (digitalRead(53) == HIGH)
            {
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Cashout in progress");
                  while (credits > 0)
                      {
                        digitalWrite(54, HIGH);
                        if (digitalRead(20) == LOW && coinout == false)
                        {
                          credits--;
                          coinout = true;
                        }
                        if (digitalRead(20) == HIGH && coinout == true)
                        {
                          coinout = false;
                        }
                      }
                digitalWrite(54, LOW);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
            }
   
  while (digitalRead(7) == HIGH)
  {
     
            // credit in test while 7 is high
            if (digitalRead(21) == HIGH && coinin == true)
            {
              coinin = false;
            }
             
            if (digitalRead(21) == LOW && coinin == false)
            {
              credits++;
              coinin = true;
              lcd.setCursor(0,0);
              lcd.print("Credit Accepted");
              lcd.setCursor(0,2);
              lcd.print("Credits = ");
              lcd.print(credits);
              lcd.setCursor(10,2);
            }
             
            // test for cashout while 7 is high 
            if (digitalRead(53) == HIGH)
            {
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Cashout in progress");
                  while (credits > 0)
                      {
                        digitalWrite(54, HIGH);
                        if (digitalRead(20) == LOW && coinout == false)
                        {
                          credits--;
                          coinout = true;
                        }
                        if (digitalRead(20) == HIGH && coinout == true)
                        {
                          coinout = false;
                        }
                      }
                digitalWrite(54, LOW);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
            }
             
            // h12 button test
             
            if (h12 == true && digitalRead(6) == LOW)
            {
              h12 = false;
            }
             
            if (digitalRead(6) == HIGH && bet12 < 9 && credits > 0 && h12 == false)
            {
                bet12++;
                digitalWrite(23, LOW);
                shiftOut(22, 24, MSBFIRST, dec_digits[bet12]); 
                digitalWrite(23, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-2 @ ");
                lcd.print(h12bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h12 = true;
            }
             
            // h13 button test
             
            if (h13 == true && digitalRead(5) == LOW)
            {
              h13 = false;
            }
           
            if (digitalRead(5) == HIGH && bet13 < 9 && credits > 0 && h13 == false)
            {
                bet13++;
                digitalWrite(26, LOW);
                shiftOut(25, 27, MSBFIRST, dec_digits[bet13]); 
                digitalWrite(26, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-3 @ ");
                lcd.print(h13bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h13 = true;
            }
             
            // h14 button test
             
            if (h14 == true && digitalRead(4) == LOW)
            {
              h14 = false;
            }
           
            if (digitalRead(4) == HIGH && bet14 < 9 && credits > 0 && h14 == false)
            {
                bet14++;
                digitalWrite(29, LOW);
                shiftOut(28, 30, MSBFIRST, dec_digits[bet14]); 
                digitalWrite(29, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-4 @ ");
                lcd.print(h14bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h14 = true;
            }
           
            // h15 button test
             
            if (h15 == true && digitalRead(3) == LOW)
            {
              h15 = false;
            }
             
            if (digitalRead(3) == HIGH && bet15 < 9 && credits > 0 && h15 == false)
            {
                bet15++;
                digitalWrite(32, LOW);
                shiftOut(31, 33, MSBFIRST, dec_digits[bet15]); 
                digitalWrite(32, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-5 @ ");
                lcd.print(h15bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h15 = true;
            }
             
            // h23 button test
             
            if (h23 == true && digitalRead(2) == LOW)
            {
              h23 = false;
            }
           
            if (digitalRead(2) == HIGH && bet23 < 9 && credits > 0 && h23 == false)
            {
                bet23++;
                digitalWrite(35, LOW);
                shiftOut(34, 36, MSBFIRST, dec_digits[bet23]); 
                digitalWrite(35, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-3 @ ");
                lcd.print(h23bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h23 = true;
            }
             
            // h24 button test
             
            if (h24 == true && digitalRead(14) == LOW)
            {
              h24 = false;
            }
             
            if (digitalRead(14) == HIGH && bet24 < 9 && credits > 0 && h24 == false)
            {
                bet24++;
                digitalWrite(38, LOW);
                shiftOut(37, 39, MSBFIRST, dec_digits[bet24]); 
                digitalWrite(38, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-4 @ ");
                lcd.print(h24bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h24 = true;
            }
             
            // h25 button test
             
            if (h25 == true && digitalRead(15) == LOW)
            {
              h25 = false;
            }
           
            if (digitalRead(15) == HIGH && bet25 < 9 && credits > 0 && h25 == false)
            {
                bet25++;   
                digitalWrite(41, LOW);
                shiftOut(40, 42, MSBFIRST, dec_digits[bet25]); 
                digitalWrite(41, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-5 @ ");
                lcd.print(h25bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h25 = true;
            }
             
            // h34 button test
             
            if (h34 == true && digitalRead(16) == LOW)
            {
              h34 = false;
            }
           
            if (digitalRead(16) == HIGH && bet34 < 9 && credits > 0 && h34 == false)
            {
                bet34++; 
                digitalWrite(44, LOW);
                shiftOut(43, 45, MSBFIRST, dec_digits[bet34]); 
                digitalWrite(44, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 3-4 @ ");
                lcd.print(h34bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h34 = true;
            }
            
            // h35 button test
             
            if (h35 == true && digitalRead(17) == LOW)
            {
              h35 = false;
            }
           
            if (digitalRead(17) == HIGH && bet35 < 9 && credits > 0 && h35 == false)
            {
                bet35++;
                digitalWrite(47, LOW);
                shiftOut(46, 48, MSBFIRST, dec_digits[bet35]); 
                digitalWrite(47, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 3-5 @ ");
                lcd.print(h35bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h35 = true;
            }
             
            // h45 button test
             
            if (h45 == true && digitalRead(52) == LOW)
            {
              h45 = false;
            }
           
            if (digitalRead(52) == HIGH && bet45 < 9 && credits > 0 && h45 == false)
            {
                bet45++;
                digitalWrite(50, LOW);
                shiftOut(49, 51, MSBFIRST, dec_digits[bet45]); 
                digitalWrite(50, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 4-5 @ ");
                lcd.print(h45bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h45 = true;
            }
             
 
               
  }
  
}


Betting Station 4c

Video #3

Code for fun game .. no coins.

#include 

LiquidCrystal lcd(12, 13, 11, 10, 9, 8);

byte dec_digits[] = {0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b10010010,0b10000011,0b11111000,0b10000000,0b10011000 };


// button tests
boolean h12 = false;
boolean h13 = false;
boolean h14 = false;
boolean h15 = false;
boolean h23 = false;

boolean h24 = false;
boolean h25 = false;
boolean h34 = false;
boolean h35 = false;
boolean h45 = false;


// odds on horse combination
int h12bet = 0;
int h13bet = 0;
int h14bet = 0;
int h15bet = 0;
int h23bet = 0;
int h24bet = 0;
int h25bet = 0;
int h34bet = 0;
int h35bet = 0;
int h45bet = 0;

int racenumber = 0;

// bets on horse combination
int bet12 = 0;
int bet13 = 0;
int bet14 = 0;
int bet15 = 0;
int bet23 = 0;
int bet24 = 0;
int bet25 = 0;
int bet34 = 0;
int bet35 = 0;
int bet45 = 0;

long lastrace = 0;
long x = 0;
long y = 0;

int credits = 75;

void setup() 
{  
  pinMode(22, OUTPUT);
  pinMode(23, OUTPUT);
  pinMode(24, OUTPUT);

  pinMode(25, OUTPUT);
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);

  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);

  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);

  pinMode(37, OUTPUT);
  pinMode(38, OUTPUT);
  pinMode(39, OUTPUT);

  pinMode(40, OUTPUT);
  pinMode(41, OUTPUT);
  pinMode(42, OUTPUT);

  pinMode(43, OUTPUT);
  pinMode(44, OUTPUT);
  pinMode(45, OUTPUT);

  pinMode(46, OUTPUT);
  pinMode(47, OUTPUT);
  pinMode(48, OUTPUT);

  pinMode(49, OUTPUT);
  pinMode(50, OUTPUT);
  pinMode(51, OUTPUT);

  pinMode(6, INPUT);
  pinMode(5, INPUT);
  pinMode(4, INPUT);
  pinMode(3, INPUT);
  pinMode(2, INPUT);

  pinMode(55, INPUT);
  pinMode(56, INPUT);
  pinMode(57, INPUT);
  pinMode(58, INPUT);
  pinMode(59, INPUT);
  
  pinMode(7, INPUT);     // signal from countdown clock
  pinMode(53, INPUT);    // cashout button
  pinMode(54, OUTPUT);   // cashout signal to turn on hopper
  pinMode(21, INPUT);    // coin in break beam
  pinMode(20, INPUT);    // cashout sensor
  
  digitalWrite(54, LOW);
  

  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Fun Mode Race");
  lcd.setCursor(0,4);
  lcd.print(racenumber);
  lcd.print(" of 25");
  lcd.setCursor(10,2);
  clearscreen();
  Serial.begin(9600);
}



void clearscreen()
{
      digitalWrite(23, LOW);
      shiftOut(22, 24, MSBFIRST, dec_digits[0]); 
      digitalWrite(23, HIGH);
      
      digitalWrite(26, LOW);
      shiftOut(25, 27, MSBFIRST, dec_digits[0]); 
      digitalWrite(26, HIGH);
  
      digitalWrite(29, LOW);
      shiftOut(28, 30, MSBFIRST, dec_digits[0]); 
      digitalWrite(29, HIGH);
  
      digitalWrite(32, LOW);
      shiftOut(31, 33, MSBFIRST, dec_digits[0]); 
      digitalWrite(32, HIGH);
  
      digitalWrite(35, LOW);
      shiftOut(34, 36, MSBFIRST, dec_digits[0]); 
      digitalWrite(35, HIGH);
  
      digitalWrite(38, LOW);
      shiftOut(37, 39, MSBFIRST, dec_digits[0]); 
      digitalWrite(38, HIGH);
      
      digitalWrite(41, LOW);
      shiftOut(40, 42, MSBFIRST, dec_digits[0]); 
      digitalWrite(41, HIGH);
  
      digitalWrite(44, LOW);
      shiftOut(43, 45, MSBFIRST, dec_digits[0]); 
      digitalWrite(44, HIGH);
  
      digitalWrite(47, LOW);
      shiftOut(46, 48, MSBFIRST, dec_digits[0]); 
      digitalWrite(47, HIGH);
  
      digitalWrite(50, LOW);
      shiftOut(49, 51, MSBFIRST, dec_digits[0]); 
      digitalWrite(50, HIGH);

      bet12 = 0;
      bet13 = 0;
      bet14 = 0;
      bet15 = 0;
      bet23 = 0;
      
      bet24 = 0;
      bet25 = 0;
      bet34 = 0;
      bet35 = 0;
      bet45 = 0;
}

void loop()
{
   if (Serial.available() > 0 && Serial.available() != lastrace)
  {
    x = Serial.parseInt();
    lastrace = x;
    
    // get digit 5 for last race
    
    y = int(x * .1); // 12345 = 1234.5
    y = y * 10; // 12340
    y = x - y;  //12345 - 12340 = 5
    
    // pay out for last race
    
    if (y == 0)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-2 Winner ");
      lcd.print(h12bet * bet12);
      lcd.setCursor(0,2);
      credits = credits + (h12bet * bet12);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    }  

    else if (y == 1)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-3 Winner ");
      lcd.print(h13bet * bet13);
      lcd.setCursor(0,2);
      credits = credits + (h13bet * bet13);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 2)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-4 Winner ");
      lcd.print(h14bet * bet14);
      lcd.setCursor(0,2);
      credits = credits + (h12bet * bet12);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 3)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("1-5 Winner ");
      lcd.print(h15bet * bet15);
      lcd.setCursor(0,2);
      credits = credits + (h15bet * bet15);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 4)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-3 Winner ");
      lcd.print(h23bet * bet23);
      lcd.setCursor(0,2);
      credits = credits + (h23bet * bet23);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 5)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-4 Winner ");
      lcd.print(h24bet * bet24);
      lcd.setCursor(0,2);
      credits = credits + (h24bet * bet24);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 6)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("2-5 Winner ");
      lcd.print(h25bet * bet25);
      lcd.setCursor(0,2);
      credits = credits + (h25bet * bet25);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 7)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("3-4 Winner ");
      lcd.print(h34bet * bet34);
      lcd.setCursor(0,2);
      credits = credits + (h34bet * bet34);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    else if (y == 8)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("3-5 Winner ");
      lcd.print(h35bet * bet35);
      lcd.setCursor(0,2);
      credits = credits + (h35bet * bet35);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    }     
    
    else if (y == 9)
    {

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("4-5 Winner ");
      lcd.print(h45bet * bet45);
      lcd.setCursor(0,2);
      credits = credits + (h45bet * bet45);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    } 
    
    delay(2000);
    
      racenumber++;
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Number ");
      lcd.print(racenumber);
      lcd.print(" of 25");
      lcd.setCursor(0,2);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
    
    
      
    int nextraceodds = int(x * .001);  // 12345 = 12
    
    switch(nextraceodds)
        {
          case 10:
            h12bet = 14;
            h13bet = 9;
            h14bet = 39;
            h15bet = 5;
            h23bet = 11;
            h24bet = 47;
            h25bet = 6;
            h34bet = 23;
            h35bet = 3;
            h45bet = 12;
          break;
    
          case 11:
            h12bet = 9;
            h13bet = 21;
            h14bet = 11;
            h15bet = 36;
            h23bet = 6;
            h24bet = 3;
            h25bet = 10;
            h34bet = 7;
            h35bet = 23;
            h45bet = 12;
          break;
          
          case 12:
            h12bet = 19;
            h13bet = 3;
            h14bet = 6;
            h15bet = 25;
            h23bet = 9;
            h24bet = 18;
            h25bet = 76;
            h34bet = 4;
            h35bet = 17;
            h45bet = 34;
          break;
          
          case 13:
            h12bet = 10;
            h13bet = 7;
            h14bet = 6;
            h15bet = 4;
            h23bet = 23;
            h24bet = 20;
            h25bet = 13;
            h34bet = 14;
            h35bet = 9;
            h45bet = 8;
          break;
          
          case 14:
            h12bet = 2;
            h13bet = 34;
            h14bet = 8;
            h15bet = 5;
            h23bet = 49;
            h24bet = 12;
            h25bet = 7;
            h34bet = 200;
            h35bet = 119;
            h45bet = 29;
          break;
          
          case 15:
            h12bet = 95;
            h13bet = 4;
            h14bet = 9;
            h15bet = 37;
            h23bet = 21;
            h24bet = 49;
            h25bet = 200;
            h34bet = 2;
            h35bet = 8;
            h45bet = 19;
          break;
          
          case 16:
            h12bet = 59;
            h13bet = 5;
            h14bet = 23;
            h15bet = 18;
            h23bet = 9;
            h24bet = 42;
            h25bet = 33;
            h34bet = 4;
            h35bet = 3;
            h45bet = 14;
          break;
          
          case 17:
            h12bet = 32;
            h13bet = 44;
            h14bet = 109;
            h15bet = 25;
            h23bet = 5;
            h24bet = 12;
            h25bet = 3;
            h34bet = 17;
            h35bet = 4;
            h45bet = 10;
          break;
          
          case 18:
            h12bet = 4;
            h13bet = 8;
            h14bet = 13;
            h15bet = 5;
            h23bet = 10;
            h24bet = 16;
            h25bet = 6;
            h34bet = 33;
            h35bet = 12;
            h45bet = 20;
          break;
          
          case 19:
            h12bet = 2;
            h13bet = 7;
            h14bet = 5;
            h15bet = 8;
            h23bet = 15;
            h24bet = 11;
            h25bet = 17;
            h34bet = 38;
            h35bet = 61;
            h45bet = 43;
          break;
    
          case 20:
            h12bet = 38;
            h13bet = 2;
            h14bet = 7;
            h15bet = 24;
            h23bet = 16;
            h24bet = 60;
            h25bet = 200;
            h34bet = 3;
            h35bet = 10;
            h45bet = 37;
          break;
          
          case 21:
            h12bet = 8;
            h13bet = 161;
            h14bet = 12;
            h15bet = 24;
            h23bet = 26;
            h24bet = 2;
            h25bet = 4;
            h34bet = 40;
            h35bet = 80;
            h45bet = 6;
          break;
          
          case 22:
            h12bet = 6;
            h13bet = 12;
            h14bet = 3;
            h15bet = 36;
            h23bet = 16;
            h24bet = 4;
            h25bet = 49;
            h34bet = 8;
            h35bet = 11;
            h45bet = 24;
          break;
          
          case 23:
            h12bet = 8;
            h13bet = 29;
            h14bet = 200;
            h15bet = 9;
            h23bet = 6;
            h24bet = 42;
            h25bet = 2;
            h34bet = 159;
            h35bet = 7;
            h45bet = 47;
          break;
          
          case 24:
            h12bet = 2;
            h13bet = 47;
            h14bet = 108;
            h15bet = 18;
            h23bet = 17;
            h24bet = 6;
            h25bet = 3;
            h34bet = 20;
            h35bet = 16;
            h45bet = 19;
          break;
    
          case 25:
            h12bet = 8;
            h13bet = 43;
            h14bet = 108;
            h15bet = 18;
            h23bet = 17;
            h24bet = 6;
            h25bet = 3;
            h34bet = 20;
            h35bet = 16;
            h45bet = 19;
          break;
          
          case 26:
            h12bet = 2;
            h13bet = 8;
            h14bet = 4;
            h15bet = 15;
            h23bet = 14;
            h24bet = 7;
            h25bet = 26;
            h34bet = 29;
            h35bet = 107;
            h45bet = 88;
          break;
          
          case 27:
            h12bet = 5;
            h13bet = 7;
            h14bet = 28;
            h15bet = 14;
            h23bet = 3;
            h24bet = 12;
            h25bet = 6;
            h34bet = 16;
            h35bet = 8;
            h45bet = 33;
          break;
    
          case 28:
            h12bet = 3;
            h13bet = 19;
            h14bet = 2;
            h15bet = 21;
            h23bet = 38;
            h24bet = 4;
            h25bet = 48;
            h34bet = 9;
            h35bet = 99;
            h45bet = 24;
          break;
    
          case 29:
            h12bet = 27;
            h13bet = 9;
            h14bet = 136;
            h15bet = 13;
            h23bet = 4;
            h24bet = 61;
            h25bet = 6;
            h34bet = 20;
            h35bet = 2;
            h45bet = 3;
          break;
    
          case 30:
            h12bet = 2;
            h13bet = 7;
            h14bet = 63;
            h15bet = 12;
            h23bet = 3;
            h24bet = 26;
            h25bet = 5;
            h34bet = 21;
            h35bet = 4;
            h45bet = 36;
          break;
    
          case 31:
            h12bet = 11;
            h13bet = 14;
            h14bet = 6;
            h15bet = 43;
            h23bet = 7;
            h24bet = 3;
            h25bet = 21;
            h34bet = 4;
            h35bet = 28;
            h45bet = 12;
          break;
    
          case 32:
            h12bet = 8;
            h13bet = 86;
            h14bet = 18;
            h15bet = 17;
            h23bet = 19;
            h24bet = 3;
            h25bet = 4;
            h34bet = 30;
            h35bet = 40;
            h45bet = 6;
          break;
    
          case 33:
            h12bet = 14;
            h13bet = 29;
            h14bet = 6;
            h15bet = 109;
            h23bet = 9;
            h24bet = 2;
            h25bet = 34;
            h34bet = 4;
            h35bet = 70;
            h45bet = 15;
          break;
    
          case 34:
            h12bet = 5;
            h13bet = 9;
            h14bet = 17;
            h15bet = 16;
            h23bet = 4;
            h24bet = 8;
            h25bet = 7;
            h34bet = 14;
            h35bet = 13;
            h45bet = 25;
          break;
        }
     // set 7 segment leds back to 0   
     
     clearscreen();
  }
  
  if (racenumber == 25)
  {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("You finished with ");
      lcd.setCursor(0,2);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
      delay(2000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("How did you do?");
      lcd.setCursor(0,2);
      lcd.print("Credits = ");
      lcd.setCursor(10,2);
      lcd.print(credits);
      delay(3000);
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("New Game Starts");
      lcd.setCursor(0,2);
      lcd.print("Next Race");
      racenumber = 0;
      credits = 75;
  }
  
  else if (digitalRead(7) == HIGH)
  {    // start else racenumber < 25      
            // h12 button test
            
            if (h12 == true && digitalRead(6) == LOW)
            {
              h12 = false;
            }
            
            if (digitalRead(6) == HIGH && bet12 < 9 && credits > 0 && h12 == false)
            {
                bet12++;
                digitalWrite(23, LOW);
                shiftOut(22, 24, MSBFIRST, dec_digits[bet12]); 
                digitalWrite(23, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-2 @ ");
                lcd.print(h12bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h12 = true;
            }
            
            // h13 button test
            
            if (h13 == true && digitalRead(5) == LOW)
            {
              h13 = false;
            }
          
            if (digitalRead(5) == HIGH && bet13 < 9 && credits > 0 && h13 == false)
            {
                bet13++;
                digitalWrite(26, LOW);
                shiftOut(25, 27, MSBFIRST, dec_digits[bet13]); 
                digitalWrite(26, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-3 @ ");
                lcd.print(h13bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h13 = true;
            }
            
            // h14 button test
            
            if (h14 == true && digitalRead(4) == LOW)
            {
              h14 = false;
            }
          
            if (digitalRead(4) == HIGH && bet14 < 9 && credits > 0 && h14 == false)
            {
                bet14++;
                digitalWrite(29, LOW);
                shiftOut(28, 30, MSBFIRST, dec_digits[bet14]); 
                digitalWrite(29, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-4 @ ");
                lcd.print(h14bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h14 = true;
            }
          
            // h15 button test
            
            if (h15 == true && digitalRead(3) == LOW)
            {
              h15 = false;
            }
            
            if (digitalRead(3) == HIGH && bet15 < 9 && credits > 0 && h15 == false)
            {
                bet15++;
                digitalWrite(32, LOW);
                shiftOut(31, 33, MSBFIRST, dec_digits[bet15]); 
                digitalWrite(32, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 1-5 @ ");
                lcd.print(h15bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h15 = true;
            }
            
            // h23 button test
            
            if (h23 == true && digitalRead(2) == LOW)
            {
              h23 = false;
            }
          
            if (digitalRead(2) == HIGH && bet23 < 9 && credits > 0 && h23 == false)
            {
                bet23++;
                digitalWrite(35, LOW);
                shiftOut(34, 36, MSBFIRST, dec_digits[bet23]); 
                digitalWrite(35, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-3 @ ");
                lcd.print(h23bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h23 = true;
            }
            
            // h24 button test
            
            if (h24 == true && digitalRead(55) == LOW)
            {
              h24 = false;
            }
            
            if (digitalRead(55) == HIGH && bet24 < 9 && credits > 0 && h24 == false)
            {
                bet24++;
                digitalWrite(38, LOW);
                shiftOut(37, 39, MSBFIRST, dec_digits[bet24]); 
                digitalWrite(38, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-4 @ ");
                lcd.print(h24bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h24 = true;
            }
            
            // h25 button test
            
            if (h25 == true && digitalRead(56) == LOW)
            {
              h25 = false;
            }
          
            if (digitalRead(56) == HIGH && bet25 < 9 && credits > 0 && h25 == false)
            {
                bet25++;   
                digitalWrite(41, LOW);
                shiftOut(40, 42, MSBFIRST, dec_digits[bet25]); 
                digitalWrite(41, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 2-5 @ ");
                lcd.print(h25bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h25 = true;
            }
            
            // h34 button test
            
            if (h34 == true && digitalRead(57) == LOW)
            {
              h34 = false;
            }
          
            if (digitalRead(57) == HIGH && bet34 < 9 && credits > 0 && h34 == false)
            {
                bet34++; 
                digitalWrite(44, LOW);
                shiftOut(43, 45, MSBFIRST, dec_digits[bet34]); 
                digitalWrite(44, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 3-4 @ ");
                lcd.print(h34bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h34 = true;
            }
           
            // h35 button test
            
            if (h35 == true && digitalRead(58) == LOW)
            {
              h35 = false;
            }
          
            if (digitalRead(58) == HIGH && bet35 < 9 && credits > 0 && h35 == false)
            {
                bet35++;
                digitalWrite(47, LOW);
                shiftOut(46, 48, MSBFIRST, dec_digits[bet35]); 
                digitalWrite(47, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 3-5 @ ");
                lcd.print(h35bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h35 = true;
            }
            
            // h45 button test
            
            if (h45 == true && digitalRead(59) == LOW)
            {
              h45 = false;
            }
          
            if (digitalRead(59) == HIGH && bet45 < 9 && credits > 0 && h45 == false)
            {
                bet45++;
                digitalWrite(50, LOW);
                shiftOut(49, 51, MSBFIRST, dec_digits[bet45]); 
                digitalWrite(50, HIGH);
                credits--;
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Bet 4-5 @ ");
                lcd.print(h45bet);
                lcd.setCursor(0,2);
                lcd.print("Credits = ");
                lcd.setCursor(10,2);
                lcd.print(credits);
                h45 = true;
            }
            
    } // end else racenumber < 25
               
  }