Built-in project · LilyGO TTGO T-Display

T-Display hello

The TTGO T-Display writes on its 135x240 screen with LilyGO’s TFT_eSPI setup and counts presses of its two buttons. The whole build, a TTGO T-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 Runs in your browser. Free, and no account needed.

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

T-Display hello · LilyGO TTGO T-Displaylive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

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

sketch.ino · LilyGO TTGO T-Display
// Hello: the T-Display's screen through TFT_eSPI, with LilyGO's setup built
// in, and its two buttons: GPIO 0 and GPIO 35, LOW when pressed.

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

int left = 0;
int right = 0;
bool leftWas = false;
bool rightWas = false;

void drawCounts()
{
    tft.setTextColor(TFT_WHITE, TFT_BLACK);
    tft.setTextPadding(100);
    tft.drawString(String("left  ") + left, 20, 80, 4);
    tft.drawString(String("right ") + right, 20, 110, 4);
}

void setup()
{
    Serial.begin(115200);
    pinMode(0, INPUT_PULLUP);
    pinMode(35, INPUT);

    tft.init();
    tft.setRotation(1); // landscape, 240 wide
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_CYAN, TFT_BLACK);
    tft.drawString("T-Display", 20, 20, 4);
    tft.fillRect(20, 54, 200, 4, TFT_MAGENTA);
    drawCounts();
}

void loop()
{
    bool l = digitalRead(0) == LOW;
    bool r = digitalRead(35) == LOW;
    if (l && !leftWas) {
        left++;
        Serial.println("left button");
        drawCounts();
    }
    if (r && !rightWas) {
        right++;
        Serial.println("right button");
        drawCounts();
    }
    leftWas = l;
    rightWas = r;
    delay(20);
}

Parts list

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

Change it and keep it

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