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;
}
}