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