3D Tetris on a 3x3x12 LED Matrix

by Max Siebenschläfer in Circuits > Electronics

3559 Views, 39 Favorites, 0 Comments

3D Tetris on a 3x3x12 LED Matrix

PrintablesMakerworld-3D-Tetris(3).png
ezgif-7-910251f08d.gif
IMG_20241212_165138637.jpg
Screenshot_20250107-180144.png

Welcome to the 3D Tetris project! This Instructable documents the creation of a 3x3x12 LED matrix that enables users to play a fully functional 3D Tetris game. The project leverages an ESP32-based development board (ESPduino) with integrated web server functionality for remote control. You can also find the project on GitHub.


Project Overview

This project was developed as part of the "Applied Microcontroller Technology" module and integrates hardware assembly, software programming, and web-based GUI design. Inspired by the game available at 3DTetris.de, the system enables interactive gameplay through a wireless web interface.

Key features include:

  1. A custom-built 3x3x12 RGB LED matrix.
  2. ESP32 microcontroller for controlling LEDs and hosting a local web server.
  3. A responsive web interface for gameplay and real-time interactions.
  4. Open-source software written in C, HTML, CSS, and JavaScript.


Features

Hardware

  1. ESPduino Controller: Combines the ESP32 Wi-Fi chip with Arduino-compatible GPIO layout.
  2. 3x3x12 LED Matrix: Comprised of 108 individually addressable PL9823 RGB LEDs.
  3. Custom Housing: 3D-printed for modularity and ease of assembly.
  4. Power Supply: Powered via USB-C with an integrated on/off switch.#


Software

  1. LED Control: Powered by the FastLED library for efficient matrix management.
  2. Game Logic: Implements Tetris gameplay mechanics including rotation, collision detection, and line clearing.
  3. Web Interface: HTML/CSS-based GUI hosted via an onboard web server, with multi-language support.


Gameplay

  1. Control Tetrominoes (Tetris blocks) through the GUI.
  2. Real-time rendering of blocks on the LED matrix.
  3. Score tracking and high-score leaderboard.
  4. Adjustable levels and difficulty scaling.
  5. High-score table to save and display the top 10 scores.
  6. Difficulty selection for custom gameplay experiences.


How It Works

LED Matrix

  1. Construction: LEDs are arranged in a 3x3x12 format, connected using PL9823-compatible drivers.
  2. Control: Each LED is addressed individually using a mapped index for 3D coordinates.


Web Interface

  1. Languages Supported: English, German, French, Spanish, Italian.
  2. Functions:
  3. Rotate blocks around X, Y, Z axes.
  4. Shift blocks along the XY-plane.
  5. Drop blocks into place.
  6. Additional Features:
  7. Live preview of the next Tetromino.
  8. Display of current score and level.
  9. High-Score Table: Saves and displays the top 10 scores along with player names. Extra entries are shown but not stored persistently.
  10. Difficulty Selection: Choose between multiple difficulty levels to adjust the gameplay experience.

Supplies

61kNQI3Iy4L._AC_UF894,1000_QL80_.jpg
ESP32 DIGITAL 16.png

Components:

  1. ESPduino (ESP32-based)
  2. Toggle switch
  3. USB-C power supply
  4. Heat shrink tubing for securing connections
  5. Insulated wires for connections
  6. 108 PL9823 RGB LEDs
  7. Solder wire (preferably lead-free)
  8. Insulated wires and welding rods 0.8 for connections
  9. 3D-printed alignment guides and 8mm Steel rods
  10. 3D-printed components (CAD files provided in NX12 format)
  11. Brass inserts with M3 threads (16 in total)
  12. M3 screws for assembly (16 in total)
  13. Plexiglas sheet for the outer cover
  14. Self-tapping screws for the USB-C port

Tools:

  1. Soldering station with fine tips

Optional:

  1. Counterweight (optional, for added stability)


3D printing:

You should print these parts with an infill of over 15%. Print the case and Plexiglas_holder with brim and support turned on because otherwise it sometimes starts to lift a bit. You can use PLA to print all the parts.

Assembly Overview

In this section, we will walk you through the step-by-step process of assembling the 3D Tetris project. The assembly process is divided into the following key stages:

  1. Soldering the Circuit: Instructions for connecting the ESPduino, LED matrix, and power supply.
  2. Building the LED Matrix: Detailed steps to construct and test the 3x3x12 LED matrix.
  3. Assembling the Case: Guidance on assembling the 3D-printed case and mounting the components securely.
  4. Installation: Configuring the system for first-time use and testing.

Follow these sections in sequence to ensure a smooth and successful assembly process. Each step is carefully detailed to make replication straightforward and efficient.

Soldering the Circuit

402729008-5437ad95-5c19-4421-8fae-848cdf8f6ef2.png

Materials Required

  1. ESPduino (ESP32-based).
  2. Toggle switch.
  3. USB-C power supply.
  4. Heat shrink tubing for securing connections.
  5. Insulated wires for connections.


Step-by-Step Guide


1. Connecting the ESPduino

  1. Solder the Digital Pin 16 of the ESPduino to the data input of the LED matrix.
  2. Connect the 5V and GND lines from the matrix to the ESPduino.

2. Adding a Power Switch

  1. Install a toggle switch between the power source and the circuit.
  2. Use heat shrink tubing to insulate all connections.

3. Testing the Circuit

  1. Upload a simple animation program to the ESPduino.
  2. Verify that the entire matrix responds as expected.
  3. Check for loose or misaligned connections and fix them if necessary.

Troubleshooting Tips

  1. Signal continuity: Verify that the cabel for the Digital Pin 16 is connected to the correct pin and doesn't have a loose contact

Building the LED Matrix

IMG20250116102005.jpg
402733581-efc0a8ec-5cf6-4eba-a693-d115f2138d98.gif
402733435-e49d8078-7da9-4bb6-8625-1d0570cd1555.gif
IMG20250116102036.jpg
IMG_20241212_002012935_HDR.jpg
402733479-0ad13c5a-561a-49d8-a7e0-99e60a45e3de.png

Materials Required

To construct the 3x3x12 LED matrix, you will need the following materials:

  1. 108 PL9823 RGB LEDs.
  2. Soldering station with fine tips.
  3. Solder wire (preferably lead-free).
  4. Insulated wires and welding rods for connections.
  5. 3D-printed alignment guides and 8mm Steel rods.

Step-by-Step Assembly Guide


1. Testing the LEDs

Before assembly, test each LED to ensure it functions correctly.

  1. Use a custom-built tester, connecting each LED to an Arduino and running a test program.
  2. Verify that the LEDs light up and change colors correctly.


2. Preparing the Matrix Frame

  1. Print the alignment guides using the provided 3D models.
  2. These guides ensure that all LEDs are positioned accurately for soldering.
  3. Insert each LED into the guide, aligning the pins consistently.


3. Soldering the LEDs

  1. Begin by soldering the power connections:
  2. Pin 2 (5V) of each LED should connect to a common power bus.
  3. Pin 3 (GND) connects to a ground bus.
  4. Use welding rods cut to size for the power and ground rails.
  5. Straighten the rods using a drill and vice to ensure clean alignment.
  6. Be sure the rods are straight, or your matrix will end up with a bend in it, like you can see in the picture.

4. Connecting Signal Lines

  1. Solder the DIN (digital input) of each LED to the DOUT (digital output) of the previous LED in the chain.
  2. Follow the predefined order to ensure signal continuity.
  3. Test connections after completing each layer to catch errors early.

5. Layer-by-Layer Assembly

  1. Build the matrix layer by layer, starting from the bottom.
  2. After completing a layer, connect it to the previous one using small jumper wires or rods for the signal line.
  3. Ensure each layer is tested before proceeding to the next.

6. Finalizing the Matrix

  1. Once all 12 layers are complete, attach the matrix to its 3D-printed base.
  2. Solder the final connections for power, ground, and data lines to the ESPduino.
  3. Secure all connections with heat shrink tubing or electrical tape for durability.

Troubleshooting Tips

  1. Non-functioning LEDs: Double-check connections and test individual LEDs if needed.
  2. Signal issues: Ensure proper alignment and avoid crossing wires. Use a multimeter to test continuity.
  3. Structural integrity: Reinforce the matrix with additional supports if necessary to prevent wobbling.
  4. Straighten the rods: Make sure that the rods are properly straightened, so that your Matrix doesn't get a curved shape.

Tools and References

For further guidance on soldering techniques and matrix assembly, you can consult:

  1. The FastLED Library Documentation for programming and troubleshooting LEDs.
  2. The video tutorial "Make Your Own SIMPLE 5x5x5 RGB LED Cube" by GreatScott for inspiration.

Assembling the Case

8.png
7.png
IMG_20250110_201153846.jpg
IMG_20250110_201146092.jpg

Materials Required

  1. 3D-printed components (CAD files provided in NX12 format).
  2. Brass inserts with M3 threads (16 in total).
  3. M3 screws for assembly.
  4. Plexiglas sheet for the outer cover.
  5. Self-tapping screws for the USB-C port.
  6. Heat-resistant washers (optional, for protecting screw points).
  7. Counterweight (optional, for added stability).

Design Overview

The case was designed in NX12 to be compact and easy to 3D print, with minimal contact on the print bed. It includes:

  1. Matrix Holder: Positioned to support the LED matrix during soldering and assembly. Pre-aligned holes ensure proper orientation of the matrix wires.
  2. Main Body: Contains slots for the ESPduino mount, USB-C port, and toggle switch.
  3. Plexiglas Cover: Attaches securely to the base with M3 screws.
  4. Counterweight Mount: Located at the bottom of the case to prevent tipping.

Step-by-Step Assembly Guide


1. Preparing the Case

  1. Print the case components using PLA or a similar material. Ensure all dimensions are accurate for proper alignment.
  2. Insert brass M3-threaded inserts into the designated holes using a soldering iron.
  3. 12 inserts are used for securing internal components (e.g., ESPduino mount, Plexiglas cover).
  4. 4 additional inserts at the bottom allow for attaching a counterweight.

2. Attaching the Matrix

  1. Secure the LED matrix to its holder using M3 screws. Ensure the wires are aligned through the designated holes in the holder for clean routing.

3. Mounting the ESPduino

  1. Attach the ESPduino to its 3D-printed mount and fasten it inside the case.
  2. Align the ESPduino’s USB and GPIO ports with the case openings for easy access.

4. Installing the USB-C Port

  1. Mount the USB-C port into its designated slot using self-tapping screws.
  2. Place heat-resistant washers on the screws to prevent damage to the case.

5. Adding the Toggle Switch

  1. Secure the toggle switch in its allocated opening.
  2. Connect the switch to the power lines using terminal connectors or soldering. 8

6. Making the Plexiglas cover

  1. Adjust the values on the box making side MakerCase. You can see the values in the picture. Modify the thickness for the kind of plexiglas you are using. Or use the manufacturing files we provided for 4mm thick plexiglas.
  2. Use some clamps and the holder to secure the cover while gluing.

7. Finalizing the Case

  1. Attach the Plexiglas cover to the main body using M3 screws.
  2. Optionally, screw a counterweight into the bottom mounts to enhance stability.

Assembly Order Notes

  1. Insert brass inserts before assembling any components.
  2. Mount the matrix first, followed by the ESPduino.
  3. Install the USB-C port and toggle switch after mounting the main components.
  4. Ensure all wires are routed neatly to avoid interference with the case or other parts.

Additional Tips

  1. Use thread-locking adhesive on screws to prevent loosening during operation.
  2. Test the electrical connections before sealing the case with the Plexiglas cover.
  3. For improved aesthetics, sand and paint the 3D-printed parts before assembly.

Installation

Screenshot 2025-01-16 130222.png
Screenshot 2025-01-19 161854.png


Software

  1. Arduino IDE: Download and install the Arduino IDE.
  2. ESP32 Board Manager: Add the ESP32 board manager by following this guide.
  3. Libraries: Install the following libraries:
  4. Via Arduino IDE Library Manager:
  5. FastLED
  6. WiFi
  7. Preferences
  8. ESPForm Library:
  9. Download the library from the ESPForm GitHub repository.
  10. Extract the downloaded ZIP file.
  11. Copy the extracted folder into the libraries directory of your Arduino IDE sketchbook folder.

Upload

  1. Clone/Download the Repository
  2. Open a terminal and run the following command to clone the repository:
git clone https://github.com/18Markus1984/3D-Tetris.git
  1. If you don't know how to us the command window, you can also manually go to the GitHub repository and download the complete project as a zip-File.
  2. Open the Project in Arduino IDE
  3. Navigate to the cloned folder and open the .ino file in the Arduino IDE.
  4. Configure the ESP32 Board
  5. Go to Tools > Board and select ESP32 Dev Module.
  6. Enable PSRAM under Tools > PSRAM.
  7. Upload the Sketch
  8. Ensure the correct COM port is selected under Tools > Port.
  9. Click the Upload button to flash the code onto the ESPduino.
  10. Connect to the ESP32's Wi-Fi Network
  11. On your computer or mobile device, connect to the Wi-Fi network:
  12. SSID: 3D-Tetris
  13. Password: 12345678
  14. Access the Web Interface
  15. Open a web browser and navigate to: http://192.168.4.1

You can now enjoy 3D Tetris using the interactive web interface!

Concluison

ezgif-5-7bcf15cd9a.gif
IMG20250116102129.jpg
IMG_20250113_092046670_HDR.jpg
IMG_9312.jpg

Results

The project successfully achieved its primary objectives, delivering:

  1. A fully functional 3D Tetris game displayed on a custom 3x3x12 LED matrix.
  2. An intuitive and user-friendly web-based control interface.
  3. A modular and scalable design, paving the way for future enhancements such as battery power and improved structural stability.

Check out the GitHub repository to explore the complete code and see the project in action.

This was a challenging but incredibly rewarding experience. I learned so much throughout the process, from designing hardware to implementing interactive software, and I’m excited to apply this knowledge to future projects. I hope you enjoy this guide and have fun building your own version of 3D Tetris! Feel free to share your thoughts or ask questions in the comments—I’d love to hear your feedback. Thank you for reading!

Future Improvements

While the project meets its initial goals, there are several areas for future enhancement:

  1. Reduce Input Latency: Optimize the system to provide smoother and more responsive gameplay.
  2. Enhance Matrix Stability: Reinforce the matrix structure to minimize movement during transport.
  3. Add Battery Support: Implement battery power to make the system portable.
  4. Optimize Collision Detection and Rotation Algorithms: Refine the software to eliminate edge-case errors, ensuring seamless gameplay.

Do Something!

This project is open-source, and contributions are always welcome! Feel free to fork the repository, suggest improvements, or even create your own version of 3D Tetris. The possibilities are endless!

Acknowledgments

This project was developed by Marvin Heins, Markus Schmidt, and Leonard Holz-Diehl as part of the "Applied Microcontroller Technology" course. A special thanks to the open-source community and the developers of the FastLED library for their invaluable tools and inspiration.