Here is a full example:
#include "TFT_eSPI.h"
TFT_eSPI tft(320, 240);
#define LCD_BACKLIGHT (72Ul)
void setup() {
Serial.begin(115200);
while(!Serial); // Wait for Serial to be ready
tft.begin();
tft.setRotation(3);
digitalWrite(LCD_BACKLIGHT, HIGH);
tft.fillScreen(TFT_BLACK);
}
void loop() {
Serial.println("Filling black");
tft.fillScreen(TFT_BLACK);
delay(1000);
Serial.println("Filling green");
tft.fillScreen(TFT_GREEN);
delay(1000);
Serial.println("Turn off backlight");
digitalWrite(LCD_BACKLIGHT, LOW);
delay(1000);
Serial.println("Turn on backlight");
digitalWrite(LCD_BACKLIGHT, HIGH);
delay(1000);
}
Uploading output:
Sketch uses 57712 bytes (11%) of program storage space. Maximum is 507904 bytes.
Device : ATSAMD51x19
Version : v1.1 [Arduino:XYZ] Mar 12 2020 17:43:33
Address : 0x0
Pages : 1024
Page Size : 512 bytes
Total Size : 512KB
Planes : 1
Lock Regions : 32
Locked : none
Security : false
BOD : false
BOR : true
Write 58336 bytes to flash (114 pages)
[==============================] 100% (114/114 pages)
Done in 0.703 seconds
Verify 58336 bytes of flash
[==============================] 100% (114/114 pages)
Verify successful
Done in 0.140 seconds
Here is a video of it running with the serial monitor in the background: Dropbox - IMG_4540.MOV - Simplify your life
(It has some stuff from CircuitPython still on the screen, which never goes away.)