If you read the first article I talked about the requirements of the arcade game Frogger, how we needed a faster processor than the Arduino and also more memory in terms of both program memory (mostly because of graphics storage) and actual RAM. The conclusion I came to was to use the quite cheap but powerful ESP8266 in the form of a NodeMCU development board. So this all worked fine and everything was great until it came to creating a controller for the game, I wanted four direction buttons and a start button, five in total (wow, see how quick I added that up!). It then became very obvious how limited the ESP8266 was in the input department. I’d already used up about 6 for controlling the display and some other pins on the board are not usable to the developer as they are reserved for other uses. No matter how I tried the most I could squeeze out of it was about 4 inputs (and that took some creativity). So with an almost heavy heart I abandoned the ES8266 as a viable option for this project.
The next contender
I already knew about the 8266’s big brother the ESP32 and indeed I’d purchased a development board some time ago which was sitting in an old biscuit tin I use for various things I order but have not used yet…. Mmmm…. biscuits….. (time passes as I go and get some). This chip was even faster than the 8266 running at 240Mhz, with usually 1Mb program memory (some boards have more) and 512K of RAM (although not all is available to the user, but a fair massive chunk actually is!). On top of all this goodness it has loads of input possibilities and variations. So this was the new chip for this project. The downside was that it costs about twice as much as the 8266 and about 3 times as much as an Arduino Nano. But this was the only way forward as far as I can see. So what do you need if you want to follow this project with me.
The parts List (see below for pics of my choices)
ESP32 development board (I’m using the NodeMCU 32S)
128×128 Colour LCD (SPI protocol and 7735 driver based)
Type D Audio Amplifier (PAM 8403)
Small 8 Ohm (or higher) speaker.
Optional rotary control or variable logarithmic resistor potentiometer – for volume control
Breadboard to mount it all on (until you build a proper board)
5 tactile push switches
Various wires
Parts Pictures
If you want to try and buy the parts that I’m using then they were all bought off AliExpress and the pictures of the various components are shown below.
NodeMCU 32S Development Board
128×128 Colour LCD (SPI protocol and 7735 driver based)
Type D Audio Amplifier (PAM 8403)
Using the ESP32
This project is going to code the ESP32 using the Arduino Environment. Now I’m aware that this is not always the easiest software to use for larger projects but it is familiar to a lot of people who work with MCU’s (i.e. Arduino) and it has actually got better with later versions of the IDE (although still lacking compared to some other development software). Please ensure you have the latest version of the IDE from https://www.arduino.cc/. At time of writing I’m using version 1.8.5 which supports multiple files and opening of header files, essential for larger projects. The development board I’m using is the NodeMCU 32S, if you are not sure what I’m mean, basically the ESP32 is the chip we are going to program and use, but we cannot just buy this chip and use it. It needs some support components, such as external program memory, USB controller (so we can program it from a computer), power regulator (as USB is 5V and the chip needs 3.3V) , a WIFI aerial (it can do Wifi too!), some other passives to glue all this together and finally bring out all the connections onto some pin headers that we can plug into a breadboard or solder onto a PCB. Phew! So you buy what is termed a “Development Board” that sorts all this for you and you can see the one I chose in the pics above. So to connect this to our computer so that we can code it with the Arduino IDE requires some extra files, see the guide below to get your board working with the Arduino IDE;
Using your ESP32 with the Arduino IDE
Connecting a display
The display used in the previous article is the same but obviously it requires different connections to the ESP32 and I has to slightly alter the 7735 driver software to work with this chip – well I say alter, all that was really required was to add an additional example to the library. The connections for this display and my dev. board are shown below but a full write up including the required driver software and running initial tests can be found in this article.
What’s Next
That should get you started ready for adding some Frogger code in the next article. Click here for the next Frogger article