Button Freak: DIY ESP32 Game Console Make Yours Now

by Random Creations in Circuits > Microcontrollers

1012 Views, 15 Favorites, 0 Comments

Button Freak: DIY ESP32 Game Console Make Yours Now

cOVER.jpg

Welcome to the Button Freak Instructable! In this guide, we'll walk through the process of creating a DIY game console using the ESP32 FireBeetle. This console features two classic games: Snake and Bouncing Ball. We'll also cover how to use a single button for navigation and gameplay, and how to include custom icons in your project.

Supplies

ESP32.jpg
LCD.jpg
BuzzerBtnd.jpg
wirebreadboard.jpg

Beetle ESP32 C6 Mini: The microcontroller for this project. [Link To Purchase]

Fermion: 2.0" 320X240 IPS TFT Display: 320x240 IPS LCD. [Link To Purchase]

Button: Single button for navigation and gameplay.

Buzzer: For sound effects.

Power Supply: Battery or USB power source.

Software

coding.jpg

Development Environment: Arduino IDE.

  1. Libraries:
  2. DFRobot_GDL - For display handling.

Icons

  1. Icons: Downloaded as 32x32 pixel images, converted into byte arrays using the image2array online tool. Convert the images to byte array and paste them in your code.

Wiring

wiring.jpg

Connect the Display:

  1. Follow the display’s wiring instructions to connect it to the ESP32. Ensure all connections are correct and secure.

Connect the Button:

  1. Wire the single button to the ESP32. This button will be used for navigating the menu and controlling gameplay.

Connect the Buzzer:

  1. Connect the buzzer to the ESP32 to enable sound effects.


Building the Hardware

Assemble the Components:

  1. Attach the display, button, and buzzer to the ESP32. If needed, use a breadboard or solder the components onto a PCB.

Enclosure (Optional):

  1. Design and build an enclosure for your game console if desired. You can use materials like acrylic or 3D-print a custom case.


Programming the Console

Clone the Repository:

git clone https://github.com/hackhobby-lab/button_freak.git

cd button-freak

Open the Project:

  1. Open the project in your Arduino IDE.

Install Required Libraries:

  1. Install the DFRobot_GDL library and any other necessary libraries.

Upload the Code:

  1. Select the correct board and port in your IDE.
  2. Upload the code to the ESP32.

Code Overview


  1. Icon Integration:

  2. Icons are included as byte arrays in the code. You can replace or add new icons by converting images into byte arrays using the
    image2cpp tool and updating the code.




const unsigned char snakeio [] PROGMEM = { //Its for snake icon
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x03, 0xff, 0x00, 0x00,
0x07, 0xff, 0x80, 0x00, 0x0f, 0x7f, 0xc0, 0x00, 0x2f, 0xff, 0xe0, 0x00, 0x3f, 0xff, 0xe0, 0x00,
0x37, 0xe7, 0xf0, 0x00, 0x03, 0x81, 0xf0, 0x00, 0x00, 0x1e, 0xf0, 0x00, 0x00, 0x0e, 0x70, 0x00,
0x00, 0x0f, 0x70, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x00, 0x0f, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0x80,
0x1f, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7f, 0xff, 0xff, 0xcf,
0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xff, 0xff, 0xf4,
0x7f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};



  1. Single Button Navigation:

  2. The single button is used to navigate through the menu and interact with the games. Here’s a simplified example of how the button is handled in the code:





void loop() {
if (buttonPressed()) {
// Navigate or interact based on current state
switch (currentState) {
case MAIN_MENU:
// Navigate menu
break;
case GAME_PLAY:
// Control game
break;
}
}
}


Game Mechanics

snake.jpg
bounce.jpg
Menu Mechanics.gif

Snake Game:

  1. Use the single button to control the snake’s direction. The game will display on the screen, and you need to avoid collisions to score high.

Bouncing Ball Game:

  1. Control the paddle with the single button to keep the ball bouncing and score points. The game mechanics are similar to classic arcade games.


Troubleshooting

Display Issues: Check all wiring connections and ensure the display library is correctly installed.

Button Response: Ensure the button is connected properly and debounce logic is implemented.

Sound Problems: Verify buzzer connections and test the sound functions in the code.

Customization

The Button Freak project combines retro gaming with modern microcontroller technology. It’s a fun and educational way to build your own game console. I hope this guide helps you in creating your own Button Freak console and customizing it to your liking.

Video

ButtonFreak A#gaming #console . Play games like #snake and #bouncingballs Powered with #beetle mini