Mini Game Console Project

Hey Everyone,

I'm fairly new to the world of microcontrollers, but I have a a decent understanding of some simple things. I am currently trying to make a mini hand held console that can play Tetris, but I haven't gotten to far. I was able to make a simple start screen, with some buttons that would advance me to the next screen or return me to the menu. Im using an Arduino mega with a 3.5 TFT LCD display. Any tips to help make the blocks and animate them would be great.
Here is my code:

#include <TFT_HX8357.h>
#include <User_Setup.h>

TFT_HX8357 tft = TFT_HX8357();
#define BLACK 0x0000
#define WHITE 0xFFFF
#define GREY 0x5AEB
#define BLUE 0x0000FF
#define RED 0xF800
#define YELLOW 0xFFFF00

const int Button = 13;
const int Button2 = 2;
int buttonState = 0;
int buttonState2 = 0;

void setup() {
tft.init();
tft.setRotation(40);
tft.fillScreen(BLACK);
tft.setTextSize(5);
tft.setTextColor(RED);
tft.setCursor(70, 1);
tft.print("TETRIS");
tft.drawRect(126.5, 185, 70, 65, BLUE);
tft.setCursor(133, 215);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.print("START");
pinMode(Button, INPUT_PULLUP);
pinMode(Button2, INPUT_PULLUP);
Serial.begin(9600);
}

void loop() {
buttonState = digitalRead(Button);
if (buttonState == LOW) { // This is the start button.
tft.fillScreen(BLACK);
displaySquare();

}
buttonState2 = digitalRead(Button2); // This represents reset button. Goes back to main menu.
if (buttonState2 == LOW) {
tft.fillScreen(BLACK);
displayMenu();
}
}
void displayMenu() {
tft.setTextSize(5);
tft.setTextColor(RED);
tft.setCursor(70, 1);
tft.print("TETRIS");
tft.drawRect(126.5, 185, 70, 65, BLUE);
tft.setCursor(133, 215);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.print("START");
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination

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