Chess Clock Problems

I am building a chess clock with arduino pro mini, but it isn't working right. My code involves bool statements, but this being my first time using them it isn't working well. Could I get some general advice on my code and any problems that may be found in it? Any help would be great. Here is the code-

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  //include the lcd library

const int fiveMin = 6;
  //button for setting the time to 5 minutes
const int tenMin = 7;
  //button for setting the time to 10 minutes
const int twentyMin = 8;
  //button for setting the time to 20 minutes
const int ssButton = A3;
  //start and stop button
const int wPlayer = 9;
  //white player's button
const int bPlayer = 10;
  //black player's button

int timeVal;
  //the time value changed when setting up the clock
bool blackTurn;
  //white's personal variable
bool whiteTurn;
  //black's personal variable
bool setupTime;
  //to decide if we are in the setup
int w;
  //white's countdown variable
int b;
  //black's countdown variable


void setup() {
  // put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(A3, INPUT);

bool whiteTurn = false;
bool blackTurn = false;

int timeVal = 0;

lcd.print("Chess Clock V1.0");
delay(2000);
lcd.clear();
  //the start up screen
setupTime = true;
}

void loop() {
  // put your main code here, to run repeatedly:
if (setupTime = true){
  lcd.print("Set Minutes-");
  lcd.setCursor(0, 1);
  lcd.print("--Min");
}
while (setupTime = true){
  if (digitalRead(fiveMin) == HIGH){
    timeVal = 300;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("5 Min");
  }
  if (digitalRead(tenMin) == HIGH){
    timeVal = 600;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("10 Min");
  }
  if (digitalRead(twentyMin) == HIGH){
    timeVal = 1200;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("20 Min");
  }
}
if (digitalRead(ssButton) == HIGH){
  setupTime = false;
  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("White");
  lcd.setCursor(10, 0);
  lcd.print("Black");
  int w = timeVal;
  int b = timeVal;
  whiteTurn = true;    
  goto gameStart;
}
gameStart:
while (whiteTurn = true){
  w--;
    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("White");
    lcd.setCursor(10, 0);
    lcd.print("Black");
    lcd.setCursor(2, 1);
    lcd.print(w);
    lcd.setCursor(10, 1);
    lcd.print(b);
    delay(1000);
    if (digitalRead(wPlayer == HIGH)){
      whiteTurn = false;
      blackTurn = true;
    }
    if (w = 0){
      lcd.clear();
      lcd.home();
      lcd.print("BLACK WIN!!!");
    }
}
while (blackTurn = true){
  b--;
    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("White");
    lcd.setCursor(10, 0);
    lcd.print("Black");
    lcd.setCursor(9, 1);
    lcd.print(b);
    lcd.setCursor(1, 1);
    lcd.print(w);
    delay(1000);
    if (digitalRead(bPlayer) == HIGH){
      blackTurn = false;
      whiteTurn = true;
    }
    if (b = 0){
      lcd.clear();
      lcd.home();
      lcd.print("WHITE WIN!!!");
    }
}

}

Oops

Multiple versions of the same.

Please remember to use code tags when posting code.

Hint:

if (digitalRead(fiveMin) == HIGH){

Better. Much better

Please post code, not tons of text. Read the very first topic telling how to get the best rom this forum.
The quoted text tells nothing. Be an engineer, be precise. We are not like Your mother, "knowing" what You need.

Hello
and take a look here.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  //include the lcd library

const int fiveMin = 6;
  //button for setting the time to 5 minutes
const int tenMin = 7;
  //button for setting the time to 10 minutes
const int twentyMin = 8;
  //button for setting the time to 20 minutes
const int ssButton = A3;
  //start and stop button
const int wPlayer = 9;
  //white player's button
const int bPlayer = 10;
  //black player's button

int timeVal;
  //the time value changed when setting up the clock
bool blackTurn;
  //white's personal variable
bool whiteTurn;
  //black's personal variable
bool setupTime;
  //to decide if we are in the setup
int w;
  //white's countdown variable
int b;
  //black's countdown variable


void setup() {
  // put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(A3, INPUT);

bool whiteTurn = false;
bool blackTurn = false;

int timeVal = 0;

lcd.print("Chess Clock V1.0");
delay(2000);
lcd.clear();
  //the start up screen
setupTime = true;
}

void loop() {
  // put your main code here, to run repeatedly:
if (setupTime = true){
  lcd.print("Set Minutes-");
  lcd.setCursor(0, 1);
  lcd.print("--Min");
}
while (setupTime = true){
  if (digitalRead(fiveMin) == HIGH){
    timeVal = 300;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("5 Min");
  }
  if (digitalRead(tenMin) == HIGH){
    timeVal = 600;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("10 Min");
  }
  if (digitalRead(twentyMin) == HIGH){
    timeVal = 1200;
    lcd.clear();
    lcd.home();
    lcd.print("Set Minutes-");
    lcd.setCursor(0, 1);
    lcd.print("20 Min");
  }
}
if (digitalRead(ssButton) == HIGH){
  setupTime = false;
  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("White");
  lcd.setCursor(10, 0);
  lcd.print("Black");
  int w = timeVal;
  int b = timeVal;
  whiteTurn = true;    
  goto gameStart;
}
gameStart:
while (whiteTurn = true){
  w--;
    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("White");
    lcd.setCursor(10, 0);
    lcd.print("Black");
    lcd.setCursor(2, 1);
    lcd.print(w);
    lcd.setCursor(10, 1);
    lcd.print(b);
    delay(1000);
    if (digitalRead(wPlayer == HIGH)){
      whiteTurn = false;
      blackTurn = true;
    }
    if (w = 0){
      lcd.clear();
      lcd.home();
      lcd.print("BLACK WIN!!!");
    }
}
while (blackTurn = true){
  b--;
    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("White");
    lcd.setCursor(10, 0);
    lcd.print("Black");
    lcd.setCursor(9, 1);
    lcd.print(b);
    lcd.setCursor(1, 1);
    lcd.print(w);
    delay(1000);
    if (digitalRead(bPlayer) == HIGH){
      blackTurn = false;
      whiteTurn = true;
    }
    if (b = 0){
      lcd.clear();
      lcd.home();
      lcd.print("WHITE WIN!!!");
    }
}

}```

Yup, still the same problem.
See reply #2, and the big hint

look at your while loops too, they have the same issue.

Just a hint, a bool is true or false.

You really don’t need blackturn and white turn….
If it’s not white’s turn, it just be black’s turn.

There’s no need to maintain separate state for both, it can only be white or black.

Nobody else is playing .

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.