Recently, I got my hands on the ESP32-2432S028R, also known as the ESP32 Cheap Yellow Display. While testing its capabilities, I came across Brian Lough's Tetris code written for the ESP32 that utilizes the Nintendo Wii Nunchuk as an input device. After playing the game with the Nunchuk for a while, I realized that I had a Nintendo 64 controller lying around, so without wasting any more time, I embarked on a journey of adapting this code to work with the Nintendo 64.
It took me roughly an hour of low-load programming mixed with debugging and gameplay to modify the code. Now, let me share the result of that endeavor with you.
Prepare the Development EnvironmentTo flash the ESP32 CYD, you need to configure the Arduino IDE, install the necessary libraries, and put the “User_Setup.h” file where it should be. You can read how to do all of that at https://randomnerdtutorials.com/cheap-yellow-display-esp32-2432s028r/
Install the "arduino-n64-controller-library" LibraryThis project only requires one additional library. You can download it at https://github.com/pothos/arduino-n64-controller-library
To install it, either unpack the content of the archive into the "…\Arduino\libraries" folder or open the Arduino IDE, click on "Sketch" -> "Include Library" -> "Add.ZIP Library…" and select the archive with the library.
Download FirmwareYou can download the archive with firmware from one of these sources:
https://sourceforge.net/projects/esp32-tetris/
https://github.com/Northstrix/ESP32-Tetris-With-Nintendo-64-Controller/
If you only need the firmware, then download the archive from SourceForge. If you also want the project photos, then download the archive from GitHub.
Flash ArduinoUpload the firmware from the "V1.0\Firmware_for_Arduino" folder into the Arduino.
Adjust the value of the "REPEAT_AFTER_HOLD" variable if needed.
Flash ESP32Upload the firmware from the "V1.0\Firmware_for_ESP32" folder into the ESP32 CYD.
Assemble the CircuitAssembling the circuit shouldn't be hard. Simply connect the Nintendo 64 controller to the Arduino, and then connect the Arduino to the ESP32 CYD.
Enjoy the ResultFinally, let's play the game!
- Press "Start" to begin/resume the game.
- Press "Z" to pause the game.
- Use the D-pad and a stick to move the piece.
- Use the "L" and "R" buttons to make a single move per click.
- Press "A" or "C Up" to rotate the piece.
I think it's also worth mentioning that the source code of this project is distributed under the MIT license. That grants you the freedom to customize, adapt, and modify it according to your needs and preferences.
And though it's a short tutorial, I believe it's a useful one.
If you found this tutorial to be useful, please consider sharing it.
Thank you for reading this tutorial.
*All images demonstrated in this step are generated by Bing Image Creator.
Comments
Please log in or sign up to comment.