Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Badminton Scoreboard Build

Status
Not open for further replies.

priyanka.nivy

New Member
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
// 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 : https://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.
 
all it takes is track the **broken link removed** and/or it's C compiler spec (some about) see what the code in #1 does and extend (complete a schematic for) it to 7-seg LED-s
(keeping you couple of weeks/months busy - depending the spare time for ...)
 
the post #3 is a good attitude -- as to believe something can be done in some way -- and it can
the point here is to drop to a right party -- which is more likely your local folks interested in such sort of things
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top