Microcontrollers are suitable for controlling devices and reading sensors, but you can also play games on them. I recently came across such a game: a Star Wars game on an Arduino Nano. It seemed like a nice project to transfer that game to the
ESP-WROOM-02, a development board based on the ESP8266 microcontroller combined with OLED and 18650 battery.
Star Wars Game on Arduino Nano
The original project can be found on the YouTube channel of
Volos Projects. He uses an Arduino Nano together with an OLED module, similar to the module from the blogs “ Adding a 128×64 pixels white OLED display to your Arduino project ” and “ Arduino breathalyzer: DIY alcohol tester with MQ-3 gas sensor and OLED display“.
On his channel, you will find many more fun and interesting Arduino projects.
The ESP-WROOM-02 development board
The 18650 battery, OLED and “joystick” make the ESP-WROOM-02 module suitable for simple games. The ESP8266 is more powerful than the ATmega328P on the Nano, so you can get more (graphical) effects and tricks without making the game too slow. You will not be able to play Crysis on it, but it is a fun and easy way to gain programming experience. The module has no sound, you can solve this by, for example, connecting a piezo buzzer. This project uses an (optional) buzzer on pin D8 (GPIO15).
Prepare your Arduino IDE for battle
First of all, you must of course already have the Arduino IDE installed on your computer. If you have not already done so, see “
Installing the Arduino IDE on Windows 10” or “ Install or upgrade to the latest Arduino IDE on Linux” to read how you can do that.
Arduino core for ESP8266 WiFi chip” must also be installed in the Arduino IDE. You can read how to do this under the chapter “Installing the ESP8266 Arduino core” in the blog “ ESP8266 NodeMcu and Arduino IDE on Linux“. The procedure is the same for Windows.
In addition, you also need two libraries for the OLED screen, namely the
ThingPulse ESP8266 OLED SSD1306 library and the Brzo I2C Library. You can easily install these two libraries in the Arduino IDE with the library manager.
If you want to know more about the above, read the blog “
WEMOS D1 Esp-Wroom-02 and Arduino IDE“, where everything is described in detail.
Star Wars Game on ESP8266 with ESP-WROOM-02 – Introduction screen on the OLED Star Wars Game Sketch
Once you’ve done all this,
you can download the sketch here from GitHub and upload it to your ESP-WROOM-02. Do not forget to switch on your ESP-WROOM-02 first with the switch on the module. Star Wars Game: Work in progress
The game works but could use some improvements. What has already been done compared to the original:
Regarding the functionality:
The graphics of the Stormtrooper and the X-Wing have been redrawn and converted to XBM format because the original graphics were not fully compatible with the ThingPulse library.
At the same time, the graphics have been expanded: a complete title screen, “Game Over” screen and a final score screen.
Graphic effects have been added: the static background is now moving, the X-Wing and Death Star are now flashing when they are hit, etc.
The two LEDs now also participate.
Some extra sound effects have been added.
The gameplay still has some bugs and needs to be improved on the whole.
Regarding the code:
The names of most variables have already been translated from Croatian to English but some have yet to be done.
Some (English) comments have already been added, but more can be added.
Star Wars Game on ESP8266 with ESP-WROOM-02 – Stormtrooper intro screen May the Force be with you
Like most projects on this website, this game is primarily a starter. Have fun and make it your own version, which is, of course, the best. Things you can do for example:
Add image and sound effects, or create a completely different theme for the game;
Use the WiFi functionality of the ESP8266, for example for a dual-player mode between two ESP-WROOM-02 modules;
Create an automatic demo mode;
You can probably also come up with enough improvements and interesting additions yourself. Have you made something nice, then let us know in the comments below!
Other projects with the ESP-WROOM-02
If games are not entirely your cup of tea, take a look at other projects with this module. For example, you can also
use it as a portable WiFi jammer / de-auther, or use it together with the MQ-3 sensor as an alcohol detector.