Betting Station - 6A, 6B, 6C, 6D, 6E

ABOUT THE VIDEO

In this video, I will do an overview of how I hooked up the 7 segment LEDs and shift registers..

This code will make the 7 segment LEDs count from 0-9



int dataPin12 = 22;
int latchPin12 = 23;
int clockPin12 = 24;

int dataPin13 = 25;
int latchPin13 = 26;
int clockPin13 = 27;

int dataPin14 = 28;
int latchPin14 = 29;
int clockPin14 = 30;

int dataPin15 = 31;
int latchPin15 = 32;
int clockPin15 = 33;

int dataPin23 = 34;
int latchPin23 = 35;
int clockPin23 = 36;

int dataPin24 = 37;
int latchPin24 = 38;
int clockPin24 = 39;

int dataPin25 = 40;
int latchPin25 = 41;
int clockPin25 = 42;

int dataPin34 = 43;
int latchPin34 = 44;
int clockPin34 = 45;

int dataPin35 = 46;
int latchPin35 = 47;
int clockPin35 = 48;

int dataPin45 = 49;
int latchPin45 = 50;
int clockPin45 = 51;

int count = 0;

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

void setup() 
{
  pinMode(latchPin12, OUTPUT);
  pinMode(clockPin12, OUTPUT);
  pinMode(dataPin12, OUTPUT);
  
  pinMode(latchPin13, OUTPUT);
  pinMode(clockPin13, OUTPUT);
  pinMode(dataPin13, OUTPUT);
  
  pinMode(latchPin14, OUTPUT);
  pinMode(clockPin14, OUTPUT);
  pinMode(dataPin14, OUTPUT);
  
  pinMode(latchPin15, OUTPUT);
  pinMode(clockPin15, OUTPUT);
  pinMode(dataPin15, OUTPUT);
  
  pinMode(latchPin23, OUTPUT);
  pinMode(clockPin23, OUTPUT);
  pinMode(dataPin23, OUTPUT);
  
  pinMode(latchPin24, OUTPUT);
  pinMode(clockPin24, OUTPUT);
  pinMode(dataPin24, OUTPUT);
  
  pinMode(latchPin25, OUTPUT);
  pinMode(clockPin25, OUTPUT);
  pinMode(dataPin25, OUTPUT);
  
  pinMode(latchPin34, OUTPUT);
  pinMode(clockPin34, OUTPUT);
  pinMode(dataPin34, OUTPUT);
  
  pinMode(latchPin35, OUTPUT);
  pinMode(clockPin35, OUTPUT);
  pinMode(dataPin35, OUTPUT);
  
  pinMode(latchPin45, OUTPUT);
  pinMode(clockPin45, OUTPUT);
  pinMode(dataPin45, OUTPUT);
}

void loop() {

    digitalWrite(latchPin12, LOW);
    shiftOut(dataPin12, clockPin12, MSBFIRST, number[count]); 
    digitalWrite(latchPin12, HIGH);
    
    digitalWrite(latchPin13, LOW);
    shiftOut(dataPin13, clockPin13, MSBFIRST, number[count]); 
    digitalWrite(latchPin13, HIGH);
    
    digitalWrite(latchPin14, LOW);
    shiftOut(dataPin14, clockPin14, MSBFIRST, number[count]); 
    digitalWrite(latchPin14, HIGH);
    
    digitalWrite(latchPin15, LOW);
    shiftOut(dataPin15, clockPin15, MSBFIRST, number[count]); 
    digitalWrite(latchPin15, HIGH);
    
    digitalWrite(latchPin23, LOW);
    shiftOut(dataPin23, clockPin23, MSBFIRST, number[count]); 
    digitalWrite(latchPin23, HIGH);
    
    digitalWrite(latchPin24, LOW);
    shiftOut(dataPin24, clockPin24, MSBFIRST, number[count]); 
    digitalWrite(latchPin24, HIGH);
    
    digitalWrite(latchPin25, LOW);
    shiftOut(dataPin25, clockPin25, MSBFIRST, number[count]); 
    digitalWrite(latchPin25, HIGH);
    
    digitalWrite(latchPin34, LOW);
    shiftOut(dataPin34, clockPin34, MSBFIRST, number[count]); 
    digitalWrite(latchPin34, HIGH);
    
    digitalWrite(latchPin35, LOW);
    shiftOut(dataPin35, clockPin35, MSBFIRST, number[count]); 
    digitalWrite(latchPin35, HIGH);
    
    digitalWrite(latchPin45, LOW);
    shiftOut(dataPin45, clockPin45, MSBFIRST, number[count]); 
    digitalWrite(latchPin45, HIGH);
    
    delay(1000);
    
    count++;
    
    if (count == 10)
    {
      count = 0;
    }
  
}


Build part 6B

Now we will make the LEDs count only if their button is pressed.

This code will make the 7 segment LEDs count from 0-9 when their button is pressed.



int dataPin12 = 22;
int latchPin12 = 23;
int clockPin12 = 24;

int dataPin13 = 25;
int latchPin13 = 26;
int clockPin13 = 27;

int dataPin14 = 28;
int latchPin14 = 29;
int clockPin14 = 30;

int dataPin15 = 31;
int latchPin15 = 32;
int clockPin15 = 33;

int dataPin23 = 34;
int latchPin23 = 35;
int clockPin23 = 36;

int dataPin24 = 37;
int latchPin24 = 38;
int clockPin24 = 39;

int dataPin25 = 40;
int latchPin25 = 41;
int clockPin25 = 42;

int dataPin34 = 43;
int latchPin34 = 44;
int clockPin34 = 45;

int dataPin35 = 46;
int latchPin35 = 47;
int clockPin35 = 48;

int dataPin45 = 49;
int latchPin45 = 50;
int clockPin45 = 51;

int button12 = 6;
int button13 = 5;
int button14 = 4;
int button15 = 3;
int button23 = 2;
int button24 = 55;
int button25 = 56;
int button34 = 57;
int button35 = 58;
int button45 = 59;

int count12 = 0;
int count13 = 0;
int count14 = 0;
int count15 = 0;
int count23 = 0;
int count24 = 0;
int count25 = 0;
int count34 = 0;
int count35 = 0;
int count45 = 0;

boolean b12p = false;
boolean b13p = false;
boolean b14p = false;
boolean b15p = false;
boolean b23p = false;
boolean b24p = false;
boolean b25p = false;
boolean b34p = false;
boolean b35p = false;
boolean b45p = false;

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

void setup() 
{
  pinMode(button12, INPUT);
  pinMode(button13, INPUT);
  pinMode(button14, INPUT);
  pinMode(button15, INPUT);
  pinMode(button23, INPUT);
  pinMode(button24, INPUT);
  pinMode(button25, INPUT);
  pinMode(button34, INPUT);
  pinMode(button35, INPUT);
  pinMode(button45, INPUT);
  
  pinMode(latchPin12, OUTPUT);
  pinMode(clockPin12, OUTPUT);
  pinMode(dataPin12, OUTPUT);
  
  pinMode(latchPin13, OUTPUT);
  pinMode(clockPin13, OUTPUT);
  pinMode(dataPin13, OUTPUT);
  
  pinMode(latchPin14, OUTPUT);
  pinMode(clockPin14, OUTPUT);
  pinMode(dataPin14, OUTPUT);
  
  pinMode(latchPin15, OUTPUT);
  pinMode(clockPin15, OUTPUT);
  pinMode(dataPin15, OUTPUT);
  
  pinMode(latchPin23, OUTPUT);
  pinMode(clockPin23, OUTPUT);
  pinMode(dataPin23, OUTPUT);
  
  pinMode(latchPin24, OUTPUT);
  pinMode(clockPin24, OUTPUT);
  pinMode(dataPin24, OUTPUT);
  
  pinMode(latchPin25, OUTPUT);
  pinMode(clockPin25, OUTPUT);
  pinMode(dataPin25, OUTPUT);
  
  pinMode(latchPin34, OUTPUT);
  pinMode(clockPin34, OUTPUT);
  pinMode(dataPin34, OUTPUT);
  
  pinMode(latchPin35, OUTPUT);
  pinMode(clockPin35, OUTPUT);
  pinMode(dataPin35, OUTPUT);
  
  pinMode(latchPin45, OUTPUT);
  pinMode(clockPin45, OUTPUT);
  pinMode(dataPin45, OUTPUT);
  
  digitalWrite(latchPin12, LOW);
  shiftOut(dataPin12, clockPin12, MSBFIRST, number[0]); 
  digitalWrite(latchPin12, HIGH);
  
  digitalWrite(latchPin13, LOW);
  shiftOut(dataPin13, clockPin13, MSBFIRST, number[0]); 
  digitalWrite(latchPin13, HIGH);
  
  digitalWrite(latchPin14, LOW);
  shiftOut(dataPin14, clockPin14, MSBFIRST, number[0]); 
  digitalWrite(latchPin14, HIGH);
  
  digitalWrite(latchPin15, LOW);
  shiftOut(dataPin15, clockPin15, MSBFIRST, number[0]); 
  digitalWrite(latchPin15, HIGH);
  
  digitalWrite(latchPin23, LOW);
  shiftOut(dataPin23, clockPin23, MSBFIRST, number[0]); 
  digitalWrite(latchPin23, HIGH);
  
  digitalWrite(latchPin24, LOW);
  shiftOut(dataPin24, clockPin24, MSBFIRST, number[0]); 
  digitalWrite(latchPin24, HIGH);
  
  digitalWrite(latchPin25, LOW);
  shiftOut(dataPin25, clockPin25, MSBFIRST, number[0]); 
  digitalWrite(latchPin25, HIGH);
  
  digitalWrite(latchPin34, LOW);
  shiftOut(dataPin34, clockPin34, MSBFIRST, number[0]); 
  digitalWrite(latchPin34, HIGH);
  
  digitalWrite(latchPin35, LOW);
  shiftOut(dataPin35, clockPin35, MSBFIRST, number[0]); 
  digitalWrite(latchPin35, HIGH);
  
  digitalWrite(latchPin45, LOW);
  shiftOut(dataPin45, clockPin45, MSBFIRST, number[0]); 
  digitalWrite(latchPin45, HIGH);
  
}

void loop() 
{
  if (digitalRead(button12) == HIGH && count12 < 9 && b12p == false)
  {
    b12p = true;
    count12++;
    digitalWrite(latchPin12, LOW);
    shiftOut(dataPin12, clockPin12, MSBFIRST, number[count12]); 
    digitalWrite(latchPin12, HIGH);
  }
  
  if (digitalRead(button12) == LOW && b12p == true)
  {
    b12p = false;
  }
    
  if (digitalRead(button13) == HIGH && count13 < 9 && b13p == false)
  {
    b13p = true;
    count13++;
    digitalWrite(latchPin13, LOW);
    shiftOut(dataPin13, clockPin13, MSBFIRST, number[count13]); 
    digitalWrite(latchPin13, HIGH);
  }
  
  if (digitalRead(button13) == LOW && b13p == true)
  {
    b13p = false;
  }
  
  
  if (digitalRead(button14) == HIGH && count14 < 9 && b14p == false)
  {
    b14p = true;
    count14++;
    digitalWrite(latchPin14, LOW);
    shiftOut(dataPin14, clockPin14, MSBFIRST, number[count14]); 
    digitalWrite(latchPin14, HIGH);
  }
  
  if (digitalRead(button14) == LOW && b14p == true)
  {
    b14p = false;
  }
  
  if (digitalRead(button15) == HIGH && count15 < 9 && b15p == false)
  {
    b15p = true;
    count15++;
    digitalWrite(latchPin15, LOW);
    shiftOut(dataPin15, clockPin15, MSBFIRST, number[count15]); 
    digitalWrite(latchPin15, HIGH);
  }
  
  if (digitalRead(button15) == LOW && b15p == true)
  {
    b15p = false;
  }
  
  if (digitalRead(button23) == HIGH && count23 < 9 && b23p == false)
  {
    b23p = true;
    count23++;
    digitalWrite(latchPin23, LOW);
    shiftOut(dataPin23, clockPin23, MSBFIRST, number[count23]); 
    digitalWrite(latchPin23, HIGH);
  }
  
  if (digitalRead(button23) == LOW && b23p == true)
  {
    b23p = false;
  }
  
  if (digitalRead(button24) == HIGH && count24 < 9 && b24p == false)
  {
    b24p = true;
    count24++;
    digitalWrite(latchPin24, LOW);
    shiftOut(dataPin24, clockPin24, MSBFIRST, number[count24]); 
    digitalWrite(latchPin24, HIGH);
  }
  
  if (digitalRead(button24) == LOW && b24p == true)
  {
    b24p = false;
  }
  
  if (digitalRead(button25) == HIGH && count25 < 9 && b25p == false)
  {
    b25p = true;
    count25++;
    digitalWrite(latchPin25, LOW);
    shiftOut(dataPin25, clockPin25, MSBFIRST, number[count25]); 
    digitalWrite(latchPin25, HIGH);
  }
  
  if (digitalRead(button25) == LOW && b25p == true)
  {
    b25p = false;
  }
  
  if (digitalRead(button34) == HIGH && count34 < 9 && b34p == false)
  {
    b34p = true;
    count34++;
    digitalWrite(latchPin34, LOW);
    shiftOut(dataPin34, clockPin34, MSBFIRST, number[count34]); 
    digitalWrite(latchPin34, HIGH);
  }
  
  if (digitalRead(button34) == LOW && b34p == true)
  {
    b34p = false;
  }
  
  if (digitalRead(button35) == HIGH && count35 < 9 && b35p == false)
  {
    b35p = true;
    count35++;
    digitalWrite(latchPin35, LOW);
    shiftOut(dataPin35, clockPin35, MSBFIRST, number[count35]); 
    digitalWrite(latchPin35, HIGH);
  }
  
  if (digitalRead(button35) == LOW && b35p == true)
  {
    b35p = false;
  }
  
  if (digitalRead(button45) == HIGH && count45 < 9 && b45p == false)
  {
    b45p = true;
    count45++;
    digitalWrite(latchPin45, LOW);
    shiftOut(dataPin45, clockPin45, MSBFIRST, number[count45]); 
    digitalWrite(latchPin45, HIGH);
  }
  
  if (digitalRead(button45) == LOW && b45p == true)
  {
    b45p = false;
  }
    
}


Build part 6C

Now we will make the LEDs count only if their button is pressed and display what bet was placed on the LCD.

This code will make the 7 segment LEDs count from 0-9 when their button is pressed.



#include 

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

int dataPin12 = 22;
int latchPin12 = 23;
int clockPin12 = 24;

int dataPin13 = 25;
int latchPin13 = 26;
int clockPin13 = 27;

int dataPin14 = 28;
int latchPin14 = 29;
int clockPin14 = 30;

int dataPin15 = 31;
int latchPin15 = 32;
int clockPin15 = 33;

int dataPin23 = 34;
int latchPin23 = 35;
int clockPin23 = 36;

int dataPin24 = 37;
int latchPin24 = 38;
int clockPin24 = 39;

int dataPin25 = 40;
int latchPin25 = 41;
int clockPin25 = 42;

int dataPin34 = 43;
int latchPin34 = 44;
int clockPin34 = 45;

int dataPin35 = 46;
int latchPin35 = 47;
int clockPin35 = 48;

int dataPin45 = 49;
int latchPin45 = 50;
int clockPin45 = 51;

int button12 = 6;
int button13 = 5;
int button14 = 4;
int button15 = 3;
int button23 = 2;
int button24 = 55;
int button25 = 56;
int button34 = 57;
int button35 = 58;
int button45 = 59;

int count12 = 0;
int count13 = 0;
int count14 = 0;
int count15 = 0;
int count23 = 0;
int count24 = 0;
int count25 = 0;
int count34 = 0;
int count35 = 0;
int count45 = 0;

int credits = 10;

boolean b12p = false;
boolean b13p = false;
boolean b14p = false;
boolean b15p = false;
boolean b23p = false;
boolean b24p = false;
boolean b25p = false;
boolean b34p = false;
boolean b35p = false;
boolean b45p = false;
boolean bcp = false;
byte number[] = { 0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b10010010,0b10000011,0b11111000,0b10000000,0b10011000 };

void setup() 
{
  lcd.clear();
  lcd.begin(16,2);
  lcd.print("Derby Time");
  lcd.setCursor(0,4);
  lcd.print("Credits = ");
  lcd.print(credits);
  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, INPUT);
  
  pinMode(button12, INPUT);
  pinMode(button13, INPUT);
  pinMode(button14, INPUT);
  pinMode(button15, INPUT);
  pinMode(button23, INPUT);
  pinMode(button24, INPUT);
  pinMode(button25, INPUT);
  pinMode(button34, INPUT);
  pinMode(button35, INPUT);
  pinMode(button45, INPUT);
  
  pinMode(latchPin12, OUTPUT);
  pinMode(clockPin12, OUTPUT);
  pinMode(dataPin12, OUTPUT);
  
  pinMode(latchPin13, OUTPUT);
  pinMode(clockPin13, OUTPUT);
  pinMode(dataPin13, OUTPUT);
  
  pinMode(latchPin14, OUTPUT);
  pinMode(clockPin14, OUTPUT);
  pinMode(dataPin14, OUTPUT);
  
  pinMode(latchPin15, OUTPUT);
  pinMode(clockPin15, OUTPUT);
  pinMode(dataPin15, OUTPUT);
  
  pinMode(latchPin23, OUTPUT);
  pinMode(clockPin23, OUTPUT);
  pinMode(dataPin23, OUTPUT);
  
  pinMode(latchPin24, OUTPUT);
  pinMode(clockPin24, OUTPUT);
  pinMode(dataPin24, OUTPUT);
  
  pinMode(latchPin25, OUTPUT);
  pinMode(clockPin25, OUTPUT);
  pinMode(dataPin25, OUTPUT);
  
  pinMode(latchPin34, OUTPUT);
  pinMode(clockPin34, OUTPUT);
  pinMode(dataPin34, OUTPUT);
  
  pinMode(latchPin35, OUTPUT);
  pinMode(clockPin35, OUTPUT);
  pinMode(dataPin35, OUTPUT);
  
  pinMode(latchPin45, OUTPUT);
  pinMode(clockPin45, OUTPUT);
  pinMode(dataPin45, OUTPUT);


  digitalWrite(latchPin12, LOW);
  shiftOut(dataPin12, clockPin12, MSBFIRST, number[0]); 
  digitalWrite(latchPin12, HIGH);
  
  digitalWrite(latchPin13, LOW);
  shiftOut(dataPin13, clockPin13, MSBFIRST, number[0]); 
  digitalWrite(latchPin13, HIGH);
  
  digitalWrite(latchPin14, LOW);
  shiftOut(dataPin14, clockPin14, MSBFIRST, number[0]); 
  digitalWrite(latchPin14, HIGH);
  
  digitalWrite(latchPin15, LOW);
  shiftOut(dataPin15, clockPin15, MSBFIRST, number[0]); 
  digitalWrite(latchPin15, HIGH);
  
  digitalWrite(latchPin23, LOW);
  shiftOut(dataPin23, clockPin23, MSBFIRST, number[0]); 
  digitalWrite(latchPin23, HIGH);
  
  digitalWrite(latchPin24, LOW);
  shiftOut(dataPin24, clockPin24, MSBFIRST, number[0]); 
  digitalWrite(latchPin24, HIGH);
  
  digitalWrite(latchPin25, LOW);
  shiftOut(dataPin25, clockPin25, MSBFIRST, number[0]); 
  digitalWrite(latchPin25, HIGH);
  
  digitalWrite(latchPin34, LOW);
  shiftOut(dataPin34, clockPin34, MSBFIRST, number[0]); 
  digitalWrite(latchPin34, HIGH);
  
  digitalWrite(latchPin35, LOW);
  shiftOut(dataPin35, clockPin35, MSBFIRST, number[0]); 
  digitalWrite(latchPin35, HIGH);
  
  digitalWrite(latchPin45, LOW);
  shiftOut(dataPin45, clockPin45, MSBFIRST, number[0]); 
  digitalWrite(latchPin45, HIGH);

  pinMode(16, INPUT); // button
  pinMode(15, OUTPUT); // relay
  pinMode(14, INPUT); // hopper
}

void loop() 
{
  
  if (digitalRead(button12) == HIGH && count12 < 9 && b12p == false)
  {
    b12p = true;
    count12++;
    digitalWrite(latchPin12, LOW);
    shiftOut(dataPin12, clockPin12, MSBFIRST, number[count12]); 
    digitalWrite(latchPin12, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 1-2 Bet ");
    lcd.print(count12);

  }
  
  if (digitalRead(button12) == LOW && b12p == true)
  {
    b12p = false;
  }
    
  if (digitalRead(button13) == HIGH && count13 < 9 && b13p == false)
  {
    b13p = true;
    count13++;
    digitalWrite(latchPin13, LOW);
    shiftOut(dataPin13, clockPin13, MSBFIRST, number[count13]); 
    digitalWrite(latchPin13, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 1-3 Bet ");
    lcd.print(count13);

  }
  
  if (digitalRead(button13) == LOW && b13p == true)
  {
    b13p = false;
  }
  
  
  if (digitalRead(button14) == HIGH && count14 < 9 && b14p == false)
  {
    b14p = true;
    count14++;
    digitalWrite(latchPin14, LOW);
    shiftOut(dataPin14, clockPin14, MSBFIRST, number[count14]); 
    digitalWrite(latchPin14, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 1-4 Bet ");
    lcd.print(count14);

  }
  
  if (digitalRead(button14) == LOW && b14p == true)
  {
    b14p = false;
  }
  
  if (digitalRead(button15) == HIGH && count15 < 9 && b15p == false)
  {
    b15p = true;
    count15++;
    digitalWrite(latchPin15, LOW);
    shiftOut(dataPin15, clockPin15, MSBFIRST, number[count15]); 
    digitalWrite(latchPin15, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 1-5 Bet ");
    lcd.print(count15);
  }
  
  if (digitalRead(button15) == LOW && b15p == true)
  {
    b15p = false;
  }
  
  if (digitalRead(button23) == HIGH && count23 < 9 && b23p == false)
  {
    b23p = true;
    count23++;
    digitalWrite(latchPin23, LOW);
    shiftOut(dataPin23, clockPin23, MSBFIRST, number[count23]); 
    digitalWrite(latchPin23, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 2-3 Bet ");
    lcd.print(count23);
  }
  
  if (digitalRead(button23) == LOW && b23p == true)
  {
    b23p = false;
  }
  
  if (digitalRead(button24) == HIGH && count24 < 9 && b24p == false)
  {
    b24p = true;
    count24++;
    digitalWrite(latchPin24, LOW);
    shiftOut(dataPin24, clockPin24, MSBFIRST, number[count24]); 
    digitalWrite(latchPin24, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 2-4 Bet ");
    lcd.print(count24);
  }
  
  if (digitalRead(button24) == LOW && b24p == true)
  {
    b24p = false;
  }
  
  if (digitalRead(button25) == HIGH && count25 < 9 && b25p == false)
  {
    b25p = true;
    count25++;
    digitalWrite(latchPin25, LOW);
    shiftOut(dataPin25, clockPin25, MSBFIRST, number[count25]); 
    digitalWrite(latchPin25, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 2-5 Bet ");
    lcd.print(count25);
  }
  
  if (digitalRead(button25) == LOW && b25p == true)
  {
    b25p = false;
  }
  
  if (digitalRead(button34) == HIGH && count34 < 9 && b34p == false)
  {
    b34p = true;
    count34++;
    digitalWrite(latchPin34, LOW);
    shiftOut(dataPin34, clockPin34, MSBFIRST, number[count34]); 
    digitalWrite(latchPin34, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 3-4 Bet ");
    lcd.print(count34);
  }
  
  if (digitalRead(button34) == LOW && b34p == true)
  {
    b34p = false;
  }
  
  if (digitalRead(button35) == HIGH && count35 < 9 && b35p == false)
  {
    b35p = true;
    count35++;
    digitalWrite(latchPin35, LOW);
    shiftOut(dataPin35, clockPin35, MSBFIRST, number[count35]); 
    digitalWrite(latchPin35, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 3-5 Bet ");
    lcd.print(count35);
  }
  
  if (digitalRead(button35) == LOW && b35p == true)
  {
    b35p = false;
  }
  
  if (digitalRead(button45) == HIGH && count45 < 9 && b45p == false)
  {
    b45p = true;
    count45++;
    digitalWrite(latchPin45, LOW);
    shiftOut(dataPin45, clockPin45, MSBFIRST, number[count45]); 
    digitalWrite(latchPin45, HIGH);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("Horse 4-5 Bet ");
    lcd.print(count45);
  }
  
  if (digitalRead(button45) == LOW && b45p == true)
  {
    b45p = false;
  }
    
}


Build part 6D

Now we will add credits if a coin crosses the break-beam sensor.



Build part 6E

Now we will hook up the coin hopper and cash out button.