I am trying to implement a Tic Tac Toe game that records gametime for each game on SD card using 2.8 TFT and UNO. My code is attached.
I am using this display board.
All i am getting is a white screen. Please help
new_code.ino (13.4 KB)
I am trying to implement a Tic Tac Toe game that records gametime for each game on SD card using 2.8 TFT and UNO. My code is attached.
I am using this display board.
All i am getting is a white screen. Please help
new_code.ino (13.4 KB)
The second best feature of the Arduino IDE is . It makes your code readable by human people.
void loop() {
// put your main code here, to run repeatedly:
p = ts.getPoint(); //Get touch point
if (gameScreen == 3)
{
buttonEnabled = true;
}
if (p.z > ts.pressureThreshhold) {
p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
p.y = map(p.y, TS_MAXY, TS_MINY, 0, 240);
Serial.print("X = "); Serial.print(p.x);
Serial.print("\tY = "); Serial.print(p.y);
Serial.print("\n");
if (p.x > 60 && p.x < 260 && p.y > 180 && p.y < 220 && buttonEnabled) // The user has pressed inside the red rectangle
{
buttonEnabled = false; //Disable button
Serial.println("Button Pressed") ;
resetGame();
//This is important, because the libraries are sharing pins
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
drawGameScreen();
playGame();
}
delay(10);
}
}
You can see that the pinMode()
calls are not taken after every ts.getPoint()
If the Red triangle is not pressed, that block is never entered.
I suggest that you study examples. It is wise to put the pinMode() immediately after the getPoint(). Then it is never missed.
David.
Thank you for both CTRL + T and for suggesting about pinMode()
. I will look into it.