So I need help with a scoreboard for tennis

Hi,

I'm trying, and failing to make a scoreboard for tennis.
I'd like to use a 4segment display welded to a tm1637.
I got 3 buttons, 1 for player A, player B and a reset.

With the library i use i can just display the numbers i type
serial.print(1234) will display 1234 (i think)

When i start display should be 0000.
You got the score 00,15,30,40 and when it's deuce i'd like it to say 8888.
When someone has the advantage it would read AA of AA.

I can pay like 10€'s..
This is my code so far to try to get it to count to 0000, 0015, 1500 and 1515.
But like I said, doesn't work.


#include <TM1637.h>

const int buttonPinA = 2;
const int buttonPinB = 3;
const int buttonPinC = 4;

int CLK = 6;
int DIO = 7;
TM1637 tm(CLK,DIO);


int buttonStateA = 0;
int buttonStateB = 0;

// how far in the count we are
int countValueA = 0;
int countValueB = 0;

int arrayA [] = {00,15};
int arrayB [] = {00,15};

void setup() {
  pinMode(buttonPinA, INPUT);
  pinMode(buttonPinB, INPUT);
  pinMode(buttonPinC, INPUT);
tm.init();
tm.set(5); //brightness
Serial.begin(9600);

}

void loop() {
                // player A
buttonStateA = digitalRead(buttonPinA);

if (buttonStateA == HIGH && countValueA == 0) {
  countValueA++;
  countValueA = 1;
} 

if (buttonStateA == HIGH && countValueA == 1) {
  countValueA++;
  countValueA = 2;
} 


                // player B
if (buttonStateB == HIGH && countValueB == 0) {
  countValueB++;
  countValueB = 1;
} 

if (buttonStateB == HIGH && countValueB == 1) {
  countValueB++;
  countValueB = 2;
} 


if (countValueA == 0 && countValueB == 0){
  Serial.print(0000);
}
  
if (countValueA == 1 && countValueB == 0){
  Serial.print(1500);
}

if (countValueA == 0 && countValueB == 1){
  Serial.print(0015);
}
if (countValueA == 1 && countValueB == 1){
 Serial.print(1515);
}











//RESET
if (buttonPinC == HIGH){
countValueA = 0;
countValueB = 0;
}
}

HIGH has the value 1, so that's never going to be true.

Not helpful

Hi,

I have a project that's just to difficult for me to make, I'm a beginner and this is end-game coding here.

So I'd like to make a scoreboard for tennis.
I'll use a 4d display with tm1637 attached.
3 buttons, 1 for player A, 1 player B and a reset.

As you know it's 00,15,30,40 and deuce.
and then a winner and it resets automatically.

Can someone help with the coding?

if you don’t want to learn, this seems a great ask for the Jobs and Paid Consultancy forum, make sure you mention your budget.

I’m pretty sure there are ready made projects for this… did you Google it? (look for "arduino tennis scoreboard" tons of results)

If you want to learn - take it slowly
Learn the basics of C++ and arduino and the basic logic,

Next work your way for understanding how buttons work - plenty of tutorials for that and button libraries

Write a piece of code dealing with the buttons and printing the score on the serial terminal

Then explore how your display work

Then put it all together

The forum can help along the way if you post your code / work / questions

(please read How to get the best out of this forum and post accordingly)

Hello
Post your current sketch to see how we can help.
Or do you have a budget for this job?

I'd like to work with arrays, but couldnt figure it out.
So i just put it in manually at the end.
I got time today, ill give it 1 more try.


#include <TM1637.h>

const int buttonPinA = 2;
const int buttonPinB = 3;
const int buttonPinC = 4;

int CLK = 6;
int DIO = 7;
TM1637 tm(CLK,DIO);


int buttonStateA = 0;
int buttonStateB = 0;

// how far in the count we are
int countValueA = 0;
int countValueB = 0;

int arrayA [] = {00,15);
int arrayB [] = {00,15};

void setup() {
  pinMode(buttonPinA, INPUT);
  pinMode(buttonPinB, INPUT);
  pinMode(buttonPinC, INPUT);
tm.init();
tm.set(5); //brightness
serial.begin(9600);
}

void loop() {
  // player A
buttonStateA = digitalRead(buttonPinA);

if (buttonStateA == HIGH && countValueA = 0) {
  count_value++;
  countValueA = 1
} 

if (buttonStateA == HIGH && countValueA = 1) {
  count_value++;
  countValue = 2
} 
  // player B
if (buttonStateB == HIGH && countValueB = 0) {
  count_value++;
  countValueeB = 1
} 

if (buttonStateB == HIGH && countValueB = 1) {
  count_value++;
  countValueB = 2
} 


if (countValueA = 0 && countValueB = 0){
  Serial.print(0000)
}
  
if (countValueA = 1 && countValueB = 0){
  Serial.print(1500)
}

if (countValueA = 0 && countValueB = 1){
  Serial.print(0015)
}
if (countValueA = 1 && countValueB = 1){
  Serial.print(1515)
}











//RESET
if (buttonPinC == HIGH){
countValueA = 0;
countValueB = 0;
}
}











}

do you have external pull-ups or pulldowns?

read a button tutorial first or use a button library (OneButton, Bounce, Bounce2, ...)

➜ get a simple code to work that displays when a button is pressed

Hi, @crisse
At this stage it would be good to see a circuit diagram so we can associate all the I/O that you have.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Topics merged

Is your budget 10€ for real or was that a mistake?

Comparison should be ==

Multiple instances.