Maker Pro
Maker Pro

Badminton Scoreboard Build

Status
Not open for further replies.

pradoartz

May 11, 2017
1
Joined
May 11, 2017
Messages
1
Hi,
I am building a scoreboard for my friend's badminton court. So i am planning of using Arduino Uno as the projects brain. I found a working code in internet, which is as follows.

Code
[mod edit: placed code within CODE tags to improve readability]

Code:
// Button Inputs
const int p1IncPIN=5, p1DecPIN=6, p2IncPIN=7, p2DecPIN=8;
// variable for reading the button status
int p1IncButton=0, p1DecButton=0, p2IncButton=0, p2DecButton=0;
// Video Outputs and Video Data
const int ledClockPIN=10; // to pin 10 on J1 (CLK_IN)
const int ledDataPIN=9;   // to pin 9 on J1 (DATA_IN)
const int ledLatchPIN=3;  // to pin 7 on J1 (DIMM_IN)
// Display Digit HEX Code {0-9} for Sure Electronics 12v 2-Panel 7-Segment Board
static byte displayDigit[10] = {
    0x3f, // 0
    0x06, // 1
    0x5b, // 2
    0x4f, // 3
    0x66, // 4
    0x6d, // 5
    0x7d, // 6
    0x07, // 7
    0x7f, // 8
    0x6f  // 9
  };
//set hex variable initial value
int p2_Ones=0, p2_Tens=0, p1_Ones=0, p1_Tens=0;
// set the variables for the score
int player1Score = 0, player2Score = 0;
// previous state of each button declaration
int p1IncLastButtonState = 0;
int p1DecLastButtonState = 0;
int p2IncLastButtonState = 0;
int p2DecLastButtonState = 0;

void setup(){
  // initialize the pushbutton pin as an input:
  pinMode(p1IncPIN, INPUT);
  pinMode(p1DecPIN, INPUT);
  pinMode(p2IncPIN, INPUT);
  pinMode(p2DecPIN, INPUT);

  // Set the Display Pins as outputs
  pinMode(ledLatchPIN, OUTPUT);//Latch
  pinMode(ledClockPIN, OUTPUT);//Clock
  pinMode(ledDataPIN, OUTPUT);//Data
  digitalWrite(ledLatchPIN, HIGH);
  // Initialize the display to reflect the beginning score before running loop()
  initDisplay();
}

void loop() {
  //read the Button Pins to see if one of them has been pressed
  p1IncButton = digitalRead(p1IncPIN);
  p1DecButton = digitalRead(p1DecPIN);
  p2IncButton = digitalRead(p2IncPIN);
  p2DecButton = digitalRead(p2DecPIN);

  //read the Button Pins to see if one of them has been pressed
if (p1IncButton != p1IncLastButtonState) {
    // if the state has changed, increment the counter 
    if (p1IncButton == HIGH){
      if (player1Score != 21) player1Score++;
    }
  }

  if (p1DecButton != p1DecLastButtonState) {
    // if the state has changed, increment the counter 
    if (p1DecButton == HIGH){
      if (player1Score != 0) player1Score--;
    }
  }

  if (p2IncButton != p2IncLastButtonState) {
    // if the state has changed, increment the counter 
    if (p2IncButton == HIGH){
      if (player2Score != 21) player2Score++;
    }
  }

  if (p2DecButton != p2DecLastButtonState) {
    // if the state has changed, increment the counter 
    if (p2DecButton == HIGH){
      if (player2Score != 0) player2Score--;
    }
  }

  // Check to see if both increment buttons are high - this will reset the score back to 0-0
  if (p1IncButton == HIGH && p2IncButton == HIGH) {
    initDisplay();
      // set the variables for the score at the beginning of the game
    player1Score = 0, player2Score = 0;
 
  }
  // save the current state as the last state for next time through the loop
  p1IncLastButtonState = p1IncButton;
  p1DecLastButtonState = p1DecButton;
  p2IncLastButtonState = p2IncButton;
  p2DecLastButtonState = p2DecButton;

  delay(50);
  scoreUpdate();
}

void scoreUpdate() {
  // this is used after a button is pressed to update the players score in integer form
  // needed to break down the score to pass info to the screen
  if (player1Score < 10) {
    p1_Tens = 0;
    p1_Ones = player1Score;
  }
  else if (player1Score > 9 && player1Score < 20) {
    p1_Tens = 1;
    p1_Ones = player1Score-10;
  }
  else if (player1Score > 19) {
    p1_Tens = 2;
    p1_Ones = player1Score-20;
  }

  if (player2Score < 10) {
    p2_Tens = 0;
    p2_Ones = player2Score;
  }
  else if (player2Score > 9 && player2Score < 20) {
    p2_Tens = 1;
    p2_Ones = player2Score-10;
  }
  else if (player2Score > 19) {
    p2_Tens = 2;
    p2_Ones = player2Score-20;
  }

  // call the scoreToHex function and pass the score variables
  updateLED();
}

void updateLED() { // update the LEDs based upon the information passed from scoreToHex
  digitalWrite(ledLatchPIN, HIGH);
  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p2_Ones]);//(datapin, clockpin, data) for Right Panel digit 1 - Player 2 Ones

  if (p2_Tens>0) {
    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p2_Tens]);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  }
  else {
    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  } 

  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p1_Ones]);//(datapin, clockpin, data) for Left Panel digit 1 - Player 1 Ones

  if (p1_Tens>0) {
    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p1_Tens]);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  }
  else {
    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  }   

  digitalWrite(ledLatchPIN, LOW);

}

//Initialize the display to show zero's in the one's column
void initDisplay() {
  digitalWrite(ledLatchPIN, HIGH);
  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0x3f);//(datapin, clockpin, data) for Right Panel digit 1 - Player 2 Ones
  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0x3f);//(datapin, clockpin, data) for Left Panel digit 1 - Player 1 Ones
  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens
  digitalWrite(ledLatchPIN, LOW);
}

Reference Forum link : http://forum.arduino.cc/index.php?topic=214857.0
Reference Video Link :

Question:

I can't find any schematic for this project, anyone please design me a circuit. Thanks in advance.
 
Last edited by a moderator:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,720
Joined
Nov 17, 2011
Messages
13,720
When you follow the link from youtube to the arduino forum's entry for this project, you'll find teh schematic in post #6.
The first information on tha thread is that he's
Using the SURE Electronics 2.3" 2 Digit 7-Segment LED Display Board (DE-DP22811). It is being powered by the test board that comes with the 4 Digit board.
 

duke37

Jan 9, 2011
5,364
Joined
Jan 9, 2011
Messages
5,364
pradoartz
Where did you get the type face? It is smaller than the standard used here but I find it much more readable.
Thank you
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,720
Joined
Nov 17, 2011
Messages
13,720
pradoartz
Where did you get the type face? It is smaller than the standard used here but I find it much more readable.
Thank you

Times New Roman? Have you noticed the font select button in th etop row of a post (#6 from left)?
 

TheresaHam

Sep 8, 2022
4
Joined
Sep 8, 2022
Messages
4
Hi,
I am building a scoreboard for my friend's badminton court. So i am planning of using Arduino Uno as the projects brain. I found a working code in internet, which is as follows.

Code
[mod edit: placed code within CODE tags to improve readability]


Code:
// Button Inputs[/INDENT]
[INDENT]const int p1IncPIN=5, p1DecPIN=6, p2IncPIN=7, p2DecPIN=8;[/INDENT]
[INDENT]// variable for reading the button status[/INDENT]
[INDENT]int p1IncButton=0, p1DecButton=0, p2IncButton=0, p2DecButton=0;[/INDENT]
[INDENT]// Video Outputs and Video Data[/INDENT]
[INDENT]const int ledClockPIN=10; // to pin 10 on J1 (CLK_IN)[/INDENT]
[INDENT]const int ledDataPIN=9;   // to pin 9 on J1 (DATA_IN)[/INDENT]
[INDENT]const int ledLatchPIN=3;  // to pin 7 on J1 (DIMM_IN)[/INDENT]
[INDENT]// Display Digit HEX Code {0-9} for Sure Electronics 12v 2-Panel 7-Segment Board[/INDENT]
[INDENT]static byte displayDigit[10] = {[/INDENT]
[INDENT]    0x3f, // 0[/INDENT]
[INDENT]    0x06, // 1[/INDENT]
[INDENT]    0x5b, // 2[/INDENT]
[INDENT]    0x4f, // 3[/INDENT]
[INDENT]    0x66, // 4[/INDENT]
[INDENT]    0x6d, // 5[/INDENT]
[INDENT]    0x7d, // 6[/INDENT]
[INDENT]    0x07, // 7[/INDENT]
[INDENT]    0x7f, // 8[/INDENT]
[INDENT]    0x6f  // 9[/INDENT]
[INDENT]  };[/INDENT]
[INDENT]//set hex variable initial value[/INDENT]
[INDENT]int p2_Ones=0, p2_Tens=0, p1_Ones=0, p1_Tens=0;[/INDENT]
[INDENT]// set the variables for the score[/INDENT]
[INDENT]int player1Score = 0, player2Score = 0;[/INDENT]
[INDENT]// previous state of each button declaration[/INDENT]
[INDENT]int p1IncLastButtonState = 0;[/INDENT]
[INDENT]int p1DecLastButtonState = 0;[/INDENT]
[INDENT]int p2IncLastButtonState = 0;[/INDENT]
[INDENT]int p2DecLastButtonState = 0;[/INDENT]
[INDENT][/INDENT]
[INDENT]void setup(){[/INDENT]
[INDENT]  // initialize the pushbutton pin as an input:[/INDENT]
[INDENT]  pinMode(p1IncPIN, INPUT);[/INDENT]
[INDENT]  pinMode(p1DecPIN, INPUT);[/INDENT]
[INDENT]  pinMode(p2IncPIN, INPUT);[/INDENT]
[INDENT]  pinMode(p2DecPIN, INPUT);[/INDENT]
[INDENT][/INDENT]
[INDENT]  // Set the Display Pins as outputs[/INDENT]
[INDENT]  pinMode(ledLatchPIN, OUTPUT);//Latch[/INDENT]
[INDENT]  pinMode(ledClockPIN, OUTPUT);//Clock[/INDENT]
[INDENT]  pinMode(ledDataPIN, OUTPUT);//Data[/INDENT]
[INDENT]  digitalWrite(ledLatchPIN, HIGH);[/INDENT]
[INDENT]  // Initialize the display to reflect the beginning score before running loop()[/INDENT]
[INDENT]  initDisplay();[/INDENT]
[INDENT]}[/INDENT]
[INDENT][/INDENT]
[INDENT]void loop() {[/INDENT]
[INDENT]  //read the Button Pins to see if one of them has been pressed[/INDENT]
[INDENT]  p1IncButton = digitalRead(p1IncPIN);[/INDENT]
[INDENT]  p1DecButton = digitalRead(p1DecPIN);[/INDENT]
[INDENT]  p2IncButton = digitalRead(p2IncPIN);[/INDENT]
[INDENT]  p2DecButton = digitalRead(p2DecPIN);[/INDENT]
[INDENT][/INDENT]
[INDENT]  //read the Button Pins to see if one of them has been pressed[/INDENT]
[INDENT]if (p1IncButton != p1IncLastButtonState) {[/INDENT]
[INDENT]    // if the state has changed, increment the counter[/INDENT]
[INDENT]    if (p1IncButton == HIGH){[/INDENT]
[INDENT]      if (player1Score != 21) player1Score++;[/INDENT]
[INDENT]    }[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (p1DecButton != p1DecLastButtonState) {[/INDENT]
[INDENT]    // if the state has changed, increment the counter[/INDENT]
[INDENT]    if (p1DecButton == HIGH){[/INDENT]
[INDENT]      if (player1Score != 0) player1Score--;[/INDENT]
[INDENT]    }[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (p2IncButton != p2IncLastButtonState) {[/INDENT]
[INDENT]    // if the state has changed, increment the counter[/INDENT]
[INDENT]    if (p2IncButton == HIGH){[/INDENT]
[INDENT]      if (player2Score != 21) player2Score++;[/INDENT]
[INDENT]    }[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (p2DecButton != p2DecLastButtonState) {[/INDENT]
[INDENT]    // if the state has changed, increment the counter[/INDENT]
[INDENT]    if (p2DecButton == HIGH){[/INDENT]
[INDENT]      if (player2Score != 0) player2Score--;[/INDENT]
[INDENT]    }[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  // Check to see if both increment buttons are high - this will reset the score back to 0-0[/INDENT]
[INDENT]  if (p1IncButton == HIGH && p2IncButton == HIGH) {[/INDENT]
[INDENT]    initDisplay();[/INDENT]
[INDENT]      // set the variables for the score at the beginning of the game[/INDENT]
[INDENT]    player1Score = 0, player2Score = 0;[/INDENT]
[INDENT][/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  // save the current state as the last state for next time through the loop[/INDENT]
[INDENT]  p1IncLastButtonState = p1IncButton;[/INDENT]
[INDENT]  p1DecLastButtonState = p1DecButton;[/INDENT]
[INDENT]  p2IncLastButtonState = p2IncButton;[/INDENT]
[INDENT]  p2DecLastButtonState = p2DecButton;[/INDENT]
[INDENT][/INDENT]
[INDENT]  delay(50);[/INDENT]
[INDENT]  scoreUpdate();[/INDENT]
[INDENT]}[/INDENT]
[INDENT][/INDENT]
[INDENT]void scoreUpdate() {[/INDENT]
[INDENT]  // this is used after a button is pressed to update the players score in integer form[/INDENT]
[INDENT]  // needed to break down the score to pass info to the screen[/INDENT]
[INDENT]  if (player1Score < 10) {[/INDENT]
[INDENT]    p1_Tens = 0;[/INDENT]
[INDENT]    p1_Ones = player1Score;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else if (player1Score > 9 && player1Score < 20) {[/INDENT]
[INDENT]    p1_Tens = 1;[/INDENT]
[INDENT]    p1_Ones = player1Score-10;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else if (player1Score > 19) {[/INDENT]
[INDENT]    p1_Tens = 2;[/INDENT]
[INDENT]    p1_Ones = player1Score-20;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (player2Score < 10) {[/INDENT]
[INDENT]    p2_Tens = 0;[/INDENT]
[INDENT]    p2_Ones = player2Score;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else if (player2Score > 9 && player2Score < 20) {[/INDENT]
[INDENT]    p2_Tens = 1;[/INDENT]
[INDENT]    p2_Ones = player2Score-10;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else if (player2Score > 19) {[/INDENT]
[INDENT]    p2_Tens = 2;[/INDENT]
[INDENT]    p2_Ones = player2Score-20;[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  // call the scoreToHex function and pass the score variables[/INDENT]
[INDENT]  updateLED();[/INDENT]
[INDENT]}[/INDENT]
[INDENT][/INDENT]
[INDENT]void updateLED() { // update the LEDs based upon the information passed from scoreToHex[/INDENT]
[INDENT]  digitalWrite(ledLatchPIN, HIGH);[/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p2_Ones]);//(datapin, clockpin, data) for Right Panel digit 1 - Player 2 Ones[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (p2_Tens>0) {[/INDENT]
[INDENT]    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p2_Tens]);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else {[/INDENT]
[INDENT]    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  }[/INDENT]
[INDENT][/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p1_Ones]);//(datapin, clockpin, data) for Left Panel digit 1 - Player 1 Ones[/INDENT]
[INDENT][/INDENT]
[INDENT]  if (p1_Tens>0) {[/INDENT]
[INDENT]    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, displayDigit[p1_Tens]);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  }[/INDENT]
[INDENT]  else {[/INDENT]
[INDENT]    shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  }  [/INDENT]
[INDENT][/INDENT]
[INDENT]  digitalWrite(ledLatchPIN, LOW);[/INDENT]
[INDENT][/INDENT]
[INDENT]}[/INDENT]
[INDENT][/INDENT]
[INDENT]//Initialize the display to show zero's in the one's column[/INDENT]
[INDENT]void initDisplay() {[/INDENT]
[INDENT]  digitalWrite(ledLatchPIN, HIGH);[/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0x3f);//(datapin, clockpin, data) for Right Panel digit 1 - Player 2 Ones[/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0x3f);//(datapin, clockpin, data) for Left Panel digit 1 - Player 1 Ones[/INDENT]
[INDENT]  shiftOut(ledDataPIN, ledClockPIN, MSBFIRST, 0);//(datapin, clockpin, data) for Right Panel digit 2 - Player 2 Tens[/INDENT]
[INDENT]  digitalWrite(ledLatchPIN, LOW);[/INDENT]
[INDENT]}




Reference Forum link : http://forum.arduino.cc/index.php?topic=214857.0
Reference Video Link :

Question:

I can't find any schematic for this project, anyone please design me a circuit. Thanks in advance.
The typeface was obtained from where? Although it is smaller than the norm here, I find it to be much easier to read.
 

bertus

Moderator
Nov 8, 2019
3,322
Joined
Nov 8, 2019
Messages
3,322
Hello,

@TheresaHam , Do you realize this is an 5 years ol thread?
I will close it now.

Bertus
 
Status
Not open for further replies.
Top