ESP32 VGA Snake




Introduction: ESP32 VGA Snake

In this instructable I will show how to reproduce a classical arcade game - Snake - with an ESP32, with the output for a VGA monitor.

The resolution is 640x350 pixels, in 8 colors.

I have previously done a version with an Arduino Uno (see here), but the resolution was only 120 x 60 pixels, 4 colors.

This project is made possible by the awesome ESP32 VGA library written by Fabrizio Di Vittorio. See here for more details.

Step 1: Step 1: ESP32 Boards, Arduino IDE Installation and VGA Library Configuration.

This step is identical to Step 1 of my previous project done with an ESP32, thus just follow this link, start reading from Step 1 until the Sub-step 3 excluded.

You have than to install the FabGL VGA library, but for Snake you need the latest version: just in case it will change in the future, I put at the bottom of this step a working version in the file You can download, uncompress and rename the folder as "src" in your

"...\arduino-1.8.9\libraries" folder.

Step 2: Step 2: Uploading "Snake" to the ESP32

Download Snake.ino at the bottom of this step.
Open it with the Arduino IDE and upload it to your raw ESP32. If you have no error messages, the code should already be running.

Step 3: Step 3: Connecting the VGA Port

You need the following parts:

  • a DSUB15 Connector, i.e. a VGA female connector or a VGA cable to be cut.
  • three 270 Ohm resistors.

Connect the ESP32 GPIO pin 2, 15 and 21 to VGA Red, Green and Blue respectively, through the 270 Ohm resistors.

Connect the VGA Hsync and Vsync to ESP32 GPIO pins 17 and 4 respectively.

Connect the DSUB15 connectors pins 5, 6, 7, 8 and 10 to ESP32 GND.

For the VGA DSUB15 connector pin definition, see the picture in this step. NB, this is the soldering side of the female connector.

Step 4: Step 4: Connect the Four Buttons

The schematic in this step shows how to connect a single button (Normally Open) from +5V to the ESP32 given pin. Note that you also need to connect the ESP given pin to GND trough a 1 to 2 kOhm resistor. In this way when the button is released (open) the ESP pin is at exactly zero Volts.

More specifically, you need to connect four buttons with the following order:

  • Pin 12 to Right button
  • Pin 25 to Up button
  • Pin 14 to Left button
  • Pin 35 to Down button

Step 5: Step 5: Conclusion and Acknowledgment

If everything works properly, just connect the VGA monitor and you should be able to enjoy Snake.

I wish to express my tanks to Fabrizio Di Vittorio for his awesome ESP32 VGA library. For more details, examples, and... Space Invaders, visit his site.

If you like this project, please write a comment or share a picture of the device you build... and, over all, vote for it in the GAMES Contest!

Games Contest

Participated in the
Games Contest

Be the First to Share


    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    4 Discussions


    Question 1 year ago

    You can adapt the code to work with a RCA terminal for a use a TV ?

    Rob Cai
    Rob Cai

    Answer 1 year ago

    You would need a “TVout” library for the ESP32. As far as I know it does not exist yet, but in case someone would write it, the conversion should be not too difficult, even if not straight forward.


    Reply 1 year ago

    I don't wave a ESP32 board I have just a raspbery pi and two arduino UNO 's and the rasbery don't have operative system and one of the arduino dont have the driver instaled :-(


    1 year ago

    You can count with a vote on this project :-D