Touch Pong on the Cheap Yellow Display: a complete mini-game for the ESP32-2432S028R touchscreen
A touch-controlled Pong clone for the Cheap Yellow Display: one complete Arduino sketch, game-loop tips and troubleshooting for the ESP32-2432S028R touchscreen.

What it is
A complete, compile-checked Pong clone for the Cheap Yellow Display: drag your fingernail to move the paddle, the board plays the other side, first to five wins. One sketch, two parts, and every config quirk that trips beginners handled on the page.
What you need
- Cheap Yellow Display (ESP32-2432S028R) the single micro-USB version
- USB data cable one ships in the box; replacements must carry data
How hard
Beginner: an hour of toolchain setup (most of it downloads), then the sketch — nothing to wire.
Key Facts
- Drag your fingernail anywhere on the screen to move the left paddle; the board defends the right side; first to five wins (tap serves and restarts)
- One sketch, two parts, zero wiring: the resistive touchscreen is the controller
- Compile-checked 2026-11-13 against the pinned pairing esp32 core 2.0.17 + TFT_eSPI 2.5.43 + XPT2046_Touchscreen 1.4 (witnessmenow User_Setup.h): 331,585 bytes flash, 22,768 bytes RAM, 304,912 free — the ~150 KB sprite fits
- Not yet played on hardware: no CYD was attached to the build host — on-device QA is a publish-gate item, stated in the copy
- Smooth by design: game logic ticks at 50 Hz, rendering lands around 30–40 fps (320×240×16-bit frames over the CYD's 55 MHz SPI bus)
- Tuning knobs for difficulty (AI_SPEED, PADDLE_H, BALL_ACCEL, BALL_MAX, WIN_SCORE) sit in one block at the top of the sketch
About This Project
The first thing everyone builds on a Cheap Yellow Display — an ESP32-2432S028R Cheap Yellow Display 2.8in touch board with a 2.8-inch resistive touchscreen — is a hello-world: touch the glass, a dot appears. Fun once. The step up is usually something practical like the CYD weather station (a sibling page on this site), which needs wiring, an API key and patience.
A mini-game is the missing middle rung. Pong uses everything the board already has — screen, touch, chip — and nothing else, but it forces you through the three ideas every animated CYD project shares: reading touch continuously, moving things without blocking the processor, and redrawing without flicker. Learn them here and the weather station, dashboards and clock projects all get easier. And it's a two-evening build: about an hour to tool setup (most of it downloads), then the sketch.
The build below is ours: MCU Atlas wrote the game, and we compiled it clean against the exact pinned library versions on this page. We have not yet played it on a physical board — no CYD was attached to our build machine when this was written — so if you build it, tell us how it plays; on-hardware QA is on our list before this page is final.
What you need
The short list is the point. A Cheap Yellow Display (ESP32-2432S028R) — the single micro-USB version; our part page has specs and buying links. And a USB data cable: the board ships with one in the box, and if you supply your own it must carry data, not just charge. That's the whole list — the touchscreen is built in, and the game needs no wiring, no soldering, no SD card. Anything else on the desk is optional: a fingernail or stylus works better on the resistive screen than a flat fingertip.
Set up the toolchain
You only do this once per computer; it's the same setup as every CYD project, so follow our first project walkthrough if any step is new. The short version, with the traps called out.
First, the Arduino IDE plus the ESP32 board package: add Espressif's board index, install the esp32 by Espressif Systems package — and pick version 2.0.17, the final bug-fix release of the 2.x line, not the newest 3.x. The display library below, TFT_eSPI, has its latest release (V2.5.43) written for the 2.x core; on 3.x it needs modified library files to compile. Our compile was against 2.0.17. Then select board ESP32 Dev Module — the CYD doesn't appear by name, and any ESP32 board setting works.
Second, two libraries from the Library Manager: TFT_eSPI by Bodmer (V2.5.43, current latest) and XPT2046_Touchscreen by Paul Stoffregen (v1.4, current latest — the release that lets the touch chip sit on its own SPI port).
Third, the config everyone gets wrong: TFT_eSPI doesn't know the CYD's pins until you replace its User_Setup.h with the CYD community's ready-made file. Skipping this is the single most common reason a first CYD sketch shows a blank screen. The file sets the ILI9341 driver, the screen's SPI pins (MOSI 13, MISO 12, clock 14, CS 15, DC 2), backlight on GPIO 21 and a 55 MHz SPI speed.
PlatformIO instead? Works fine — the community repo's examples all run under PlatformIO, where selecting the CYD environment applies the display config for you (and there's a CYD2USB variant for two-port boards). Two-port board? If your ESP32-2432S028 has both micro-USB and USB-C, it's the later revision: colours come out inverted until you use the CYD2USB config or call tft.invertDisplay(1), and its USB-C port lacks the CC-line resistors to work with USB-C-to-USB-C cables — use the micro-USB port. The game itself runs the same.
The sketch
The game logic is ours; every pin number, calibration range and config fact in it comes from the sources at the bottom of the page. The complete sketch is served from this page as a plain file, cyd-touch-pong.ino (linked in the Learn more section below), byte-identical to the copy we compiled against the pinned pairing (esp32 core 2.0.17, TFT_eSPI 2.5.43, XPT2046_Touchscreen 1.4). Paste it into a new Arduino sketch and upload. Drag anywhere on the screen to move your paddle (a tap also serves the ball and restarts after a game); the board defends the right side; first to five wins.
How the game loop works
Two rules keep a game playable on a microcontroller, and both show up in loop().
Never call delay(). A delay(20) would freeze touch reading for 20 milliseconds and the paddle would feel glued to your finger. Instead the sketch calls readTouch() on every pass of loop(), then uses millis() arithmetic to step the game exactly 50 times a second (TICK_MS = 20). Anything time-based — ball speed, the AI's tracking speed — is expressed per tick, so gameplay is the same no matter how fast the rendering is.
Never draw straight to the screen mid-move. Clearing and redrawing directly on the panel makes Pong flicker, because the screen shows the half-drawn state while the SPI bus is still busy. Instead everything is drawn into an off-screen sprite (TFT_eSprite) and pushed with one pushSprite() call per frame — the display never shows an in-between state. The sprite is 320×240 pixels at 16-bit colour, about 150 KB; our compile left 304,912 bytes of RAM free, so it fits comfortably with Wi-Fi unused.
How fast does that run? One full frame is 320 × 240 × 16 bits ≈ 1.23 million bits over the 55 MHz SPI bus the CYD config sets — about 22 ms, a ceiling near 45 full frames per second before overheads. Real-world you'll see a little under that, and for Pong it's plenty smooth: game logic ticks at 50 Hz and rendering lands around 30–40 fps. If you later build something busier (an emulator, a particle toy), the standard next moves are an 8-bit sprite (half the bytes) or redrawing only the rectangles that changed.
Make it yours
Every knob that changes how the game feels is in the tuning block at the top of the sketch. AI_SPEED defaults to 2.2 — how fast the board's paddle moves per tick; 3.5 gets mean and 1.2 suits kids. PADDLE_H is your paddle's height in pixels, 50 by default; 30 makes defence hard. BALL_ACCEL (0.15) is the speed added per paddle hit — 0.4 gives short, brutal rallies. BALL_MAX caps rally speed at 6.0; raise it to 8.0 if your reactions are young. WIN_SCORE is points to win, 5 by default; 3 fits lunch-break games.
Beyond the knobs: the board's RGB LED (red GPIO 4, green 16, blue 17) is begging to flash when someone scores — two digitalWrite() lines in the scoring block. The speaker header can beep on paddle hits. And once this feels easy, making the right paddle touch-controlled on a second CYD over Wi-Fi is a genuinely fun weekend project — the hub's project list has examples of exactly that class of build.
When it misbehaves
It's nearly always config. If the paddle moves mirrored or upside-down versus your finger, the touch and screen rotations disagree: change touchscreen.setRotation(1) to 2, 3 or 4 — a known CYD quirk, not a fault. If the paddle sits a centimetre or more from your finger, that's panel calibration variance: adjust the map(p.y, 240, 3800, …) ranges, or run the community calibration sketch (six crosshair taps, prints your panel's true values).
A blank white screen with the backlight on means TFT_eSPI still has its default User_Setup.h — redo the config step above. Colours that look like a photo negative mean the two-port CYD2USB revision: use the CYD2USB config, add TFT_INVERSION_ON, or call tft.invertDisplay(1). Compile errors mentioning SPI or esp32-hal mean the ESP32 core 3.x is installed — drop back to 2.0.17 in the Boards Manager. An upload that hangs at "Connecting…" is upload speed or boot mode: set Upload Speed 115200 and hold the BOOT button until it starts.
If taps do nothing at all, check you passed the IRQ pin (XPT2046_IRQ 36) — sketches that construct the touch object without it poll differently — and that nothing else in your sketch grabbed VSPI.
More CYD builds
New to the board? Start with What is the Cheap Yellow Display? — what the board is, why it's everywhere, and which revision to buy. The practical sibling of this build is the touchscreen weather station on the CYD — same board, same touch input, real weather data. Our step-by-step first CYD project walkthrough covers this page's toolchain setup in full detail. And the Cheap Yellow Display community hub collects what people actually build on this board — clocks, dashboards, games and emulators — with pinouts and the community repo that maintains the display config this page uses.
MCU Atlas is an independent site, not affiliated with Sunton, the ESP32-Cheap-Yellow-Display project, Bodmer, Paul Stoffregen or Random Nerd Tutorials. This build's display configuration, pin numbers and calibration values build on their published documentation, cited in the tutorial below. The game sketch is original MCU Atlas code.
Source & Attribution

Illustration
How to Build It
Parts Needed
- A Cheap Yellow Display (ESP32-2432S028R) with a single micro-USB port — catalog link in the page's Parts list
- A USB data cable (micro-USB) — one ships in the box; replacements must carry data
Steps
- 1
Install the Arduino IDE and ESP32 core 2.0.17
Add Espressif's board index to the Arduino IDE, install the esp32 by Espressif Systems package — and pick version 2.0.17, the final bug-fix release of the 2.x line, not the newest 3.x. TFT_eSPI's latest release (V2.5.43) is written for the 2.x core; on 3.x it needs modified library files to compile. Then select board ESP32 Dev Module — the CYD doesn't appear by name, and any ESP32 board setting works.
- 2
Install the two libraries
From the Library Manager: TFT_eSPI by Bodmer (V2.5.43, current latest) and XPT2046_Touchscreen by Paul Stoffregen (v1.4, current latest — the release that lets the touch chip sit on its own SPI port).
- 3
Replace TFT_eSPI's User_Setup.h with the CYD config
TFT_eSPI doesn't know the CYD's pins until you replace its User_Setup.h with the CYD community's ready-made file. Skipping this is the single most common reason a first CYD sketch shows a blank screen. The file sets the ILI9341 driver, the screen's SPI pins (MOSI 13, MISO 12, clock 14, CS 15, DC 2), backlight on GPIO 21 and a 55 MHz SPI speed.
- 4
Paste the sketch and upload
The complete sketch is served from this page at /firmware/cyd-esp32-touchscreen-mini-game/cyd-touch-pong.ino — byte-identical to the copy we compiled. Paste it into a new Arduino sketch, select ESP32 Dev Module and the port, and upload. Drag anywhere on the screen to move your paddle; a tap serves the ball and restarts after a game; the board defends the right side; first to five wins. Two-port boards: use the micro-USB port, and expect inverted colours until you apply the CYD2USB config or call tft.invertDisplay(1).
- 5
If it misbehaves, it's nearly always config
Paddle mirrored or upside-down versus your finger: change touchscreen.setRotation(1) to 2, 3 or 4 — a known CYD quirk, not a fault. Paddle a centimetre or more from your finger: adjust the map(p.y, 240, 3800, ...) calibration ranges or run the community calibration sketch. Blank white screen: redo the User_Setup.h step. Compile errors mentioning SPI or esp32-hal: drop the core back to 2.0.17. Upload hanging at Connecting...: set Upload Speed 115200 and hold the BOOT button until it starts.
Bill of Materials
Parts list
2 parts · 2 linked
Heads up: some Buy links are affiliate links. If you buy through one, MCU Atlas may earn a small commission at no extra cost to you. It never changes which parts we list. How this works
1× ESP32-2432S028R
≈$15–48 per board delivered (checked 2026-11-13) — the band our Cheap Yellow Display community hub records; 2-packs often halve the per-board cost.
Learn
Docs & guides
Read these before you buy. These pages explain things; they don't sell anything.
- The complete Touch Pong sketch (.ino)Single Arduino sketch, byte-identical to the compile-checked copy (sha256 ab9b652e…); paste, upload, tap to serveDocs
- What is the Cheap Yellow Display?The lane's plain-English explainer — what the board is, why it's everywhere, which revision to buyDocs
- Your first project on a Cheap Yellow DisplayThis page's toolchain setup in full detail, step by stepDocs
- witnessmenow's ESP32-Cheap-Yellow-Display (community project)The community project behind the display config, pin documentation and CYD2USB revision notes (MIT)Docs
- Bodmer's TFT_eSPI releasesV2.5.43 is the release this page pins — written for the ESP32 Arduino core 2.x lineDocs
Related Projects




