Built-in project · Cheap Yellow Display (ESP32-2432S028R)

CYD hello

The Cheap Yellow Display writes on its own 2.8 inch screen with TFT_eSPI, set up as the board is wired, and cycles its RGB LED. The whole build, a Cheap Yellow Display, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner About 10 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $14. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • Drawing text and shapes with TFT_eSPI
  • Active-low LEDs: LOW means on
  • Screen rotation and coordinates
  • Using a board with a built-in display
  • Difficulty: Beginner
  • Time: About 10 minutes
  • Board: Cheap Yellow Display (ESP32-2432S028R)
  • Parts: 1

How it works

The Cheap Yellow Display has everything on one board, so there is nothing to wire. At startup the sketch draws on the 2.8 inch screen: a yellow greeting, the board name, and three colored blocks of red, green and blue.

Then it loops forever through the board's RGB LED. It lights red, green, then blue for 400 ms each. These LED pins are active low, so a LOW signal turns a color on. A small white bar under the matching block shows which color is lit.

Parts list

1 part, plus the jumper wires. They retail for about $14; on Mokxi they're free.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Cheap Yellow Display (ESP32-2432S028R)
// Hello: the CYD's screen through TFT_eSPI, with the board's setup built in,
// and its RGB LED, each color lit LOW.

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

const int kRed = 4;
const int kGreen = 16;
const int kBlue = 17;

void setup()
{
    Serial.begin(115200);
    pinMode(kRed, OUTPUT);
    pinMode(kGreen, OUTPUT);
    pinMode(kBlue, OUTPUT);

    tft.init();
    tft.setRotation(1); // landscape, the way the board is usually held
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_YELLOW, TFT_BLACK);
    tft.drawCentreString("Hello, CYD!", 160, 30, 4);
    tft.setTextColor(TFT_WHITE, TFT_BLACK);
    tft.drawCentreString("ESP32-2432S028R", 160, 70, 2);
    tft.fillRect(40, 120, 80, 60, TFT_RED);
    tft.fillRect(120, 120, 80, 60, TFT_GREEN);
    tft.fillRect(200, 120, 80, 60, TFT_BLUE);
    Serial.println("Screen drawn.");
}

void loop()
{
    // Red, green, blue, each lit LOW in turn.
    const int pins[3] = {kRed, kGreen, kBlue};
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) digitalWrite(pins[j], j == i ? LOW : HIGH);
        tft.fillRect(40 + i * 80, 190, 80, 8, TFT_WHITE);
        delay(400);
        tft.fillRect(40 + i * 80, 190, 80, 8, TFT_BLACK);
    }
}

Code walkthrough

The key functions of the sketch, and what each one does.

setup sketch.ino

Starts serial at 115200, sets the three LED pins (kRed, kGreen, kBlue) as outputs, then starts the screen with tft.init(). setRotation(1) gives landscape. It fills the screen black, writes the two lines of text centered at x 160, and draws the three colored rectangles.

void setup()
{
    Serial.begin(115200);
    pinMode(kRed, OUTPUT);
    pinMode(kGreen, OUTPUT);
    pinMode(kBlue, OUTPUT);

    tft.init();
    tft.setRotation(1); // landscape, the way the board is usually held
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_YELLOW, TFT_BLACK);
    tft.drawCentreString("Hello, CYD!", 160, 30, 4);
    tft.setTextColor(TFT_WHITE, TFT_BLACK);
    tft.drawCentreString("ESP32-2432S028R", 160, 70, 2);
    tft.fillRect(40, 120, 80, 60, TFT_RED);
    tft.fillRect(120, 120, 80, 60, TFT_GREEN);
    tft.fillRect(200, 120, 80, 60, TFT_BLUE);
    Serial.println("Screen drawn.");
}

loop sketch.ino

Goes through red, green and blue. For each, it writes LOW to that color's pin and HIGH to the other two, draws a white bar under the matching block, waits 400 ms, then erases the bar.

void loop()
{
    // Red, green, blue, each lit LOW in turn.
    const int pins[3] = {kRed, kGreen, kBlue};
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) digitalWrite(pins[j], j == i ? LOW : HIGH);
        tft.fillRect(40 + i * 80, 190, 80, 8, TFT_WHITE);
        delay(400);
        tft.fillRect(40 + i * 80, 190, 80, 8, TFT_BLACK);
    }
}

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • The LED is dark when you expect it on This project
    The LED is active low. Write LOW to turn a color on and HIGH to turn it off.
  • The text is sideways or off center This project
    Check the setRotation value. The sketch uses 1 for landscape, and the text positions assume a 320 pixel wide screen.
  • The screen stays dark or shows white. Cheap Yellow Display (ESP32-2432S028R)
    The backlight is on a GPIO pin you must turn on, and the display needs the right driver and pins in its setup file. Use a library configuration made for this board.
  • The RGB LED lights up the opposite way you expect. Cheap Yellow Display (ESP32-2432S028R)
    The onboard RGB LED is active LOW, so write LOW to turn a color on and HIGH to turn it off. Some pins are shared with other board functions.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.