i connected a tft display 2’ 4 inches touch to the node mcu esp 32and uploded this code it is just showing a blank screen and it is not working according to the code
Your "shorthand" above is stating this is a "two feet, four inches" screen, when I believe it is "2.4 inches". Accuracy counts. I advise you examine your work, and try again, or have a friend look at it. Often, inaccuracies can be identified, even by someone who does not know how your design works.
Are we actually dealing with an ESP32 here? The pins shown in the sketch as well as the Nodemcu name are typically associated with an ESP8266, although due to keyword spamming on listings, the confusion might perhaps be understandable.
In addition to the pins shown in the sketch I presume that you have connected GND? How is the display being powered?
Please confirm which board you are using (ESP8266 or ESP32) and as per post #2 show us exactly how you have connected everything up. Remember, we can't see your setup. Thanks.
It looks like User_Setup.h was edited incorrectly. One more question: what model of ESP32 are you using?
The touch sensor uses the same SPI pins as the display; only the CS pin should be on a different pin.
Translated with deepl.com
The 2.4-inch TFT display is only available with the ILI9341 or ST7789. The ST chip is partially compatible with the ILI, so the display will still work even if the wrong driver is selected.
Assuming an ESP32 and tft display 2’ 4 inches touch using a ILI9341 the following may help
// ESP32 TFT_eSPI library example TFT_Print_Test
// 240X320 Resolution 2.8_ SPI TFT LCD Display Touch Panel ILI9341
// File>Examples>TFT_eSPI>320 * 240>TFT_Print_Test
// in file TFT_eSPI/User_Setup_Select.h uncomment the following definition
// #include <User_Setups/Setup42_ILI9341_ESP32.h> // Setup file for ESP32 and SPI ILI9341 240x320
// in file TFT_eSPI/User_Setups/Setup42_ILI9341_ESP32.h uncomment the definitions setting pin numbers
// #define ILI9341_DRIVER
//
// #define TFT_MISO 19 // (leave TFT SDO disconnected if other SPI devices share MISO)
// #define TFT_MOSI 23
// #define TFT_SCLK 18
// #define TFT_CS 15 // Chip select control pin
// #define TFT_DC 2 // Data Command control pin
// #define TFT_RST 4 // Reset pin (could connect to RST pin) Reset input active LOW. Pull to 3.3V if not using.
// 5Volt power to display VCC if J1 is open
// LED to 3.3V
/*
Test the tft.print() viz. the libraries embedded write() function
This sketch used font 2, 4, 7
Make sure all the required fonts are loaded by editing the
User_Setup.h file in the TFT_eSPI library folder.
#########################################################################
###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
#########################################################################
*/
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
#define TFT_GREY 0x5AEB // New colour
void setup(void) {
//uint16_t ID = tft.readID();
Serial.begin(115200);
delay(2000);
Serial.println("\n\nESP32 TFT_eSPI library example TFT_Print_Test");
Serial.printf("TFT_MOSI %d\n", TFT_MOSI);
Serial.printf("TFT_MISO %d\n", TFT_MISO);
Serial.printf("TFT_SCLK %d\n", TFT_SCLK);
Serial.printf("TFT_CS %d\n", TFT_CS);
Serial.printf("TFT_DC %d\n", TFT_DC);
Serial.printf("TFT_RST %d\n", TFT_RST);
//Serial.println(ID);
tft.init();
tft.setRotation(2);
}
void loop() {
// Fill screen with random colour so we can see the effect of printing with and without
// a background colour defined
tft.fillScreen(random(0xFFFF));
// Set "cursor" at top left corner of display (0,0) and select font 2
// (cursor will move to next line automatically during printing with 'tft.println'
// or stay on the line is there is room for the text with tft.print)
tft.setCursor(0, 0, 2);
// Set the font colour to be white with a black background, set text size multiplier to 1
tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1);
// We can now plot text on screen using the "print" class
tft.println("Hello World!");
// Set the font colour to be yellow with no background, set to font 7
tft.setTextColor(TFT_YELLOW); tft.setTextFont(7);
tft.println(1234.56);
// Set the font colour to be red with black background, set to font 4
tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4);
tft.println((long)3735928559, HEX); // Should print DEADBEEF
// Set the font colour to be green with black background, set to font 4
tft.setTextColor(TFT_GREEN,TFT_BLACK);
tft.setTextFont(4);
tft.println("Groop");
tft.println("I implore thee,");
// Change to font 2
tft.setTextFont(2);
tft.println(F("my foonting turlingdromes.")); // Can store strings in FLASH to save RAM
tft.println("And hooptiously drangle me");
tft.println("with crinkly bindlewurdles,");
// This next line is deliberately made too long for the display width to test
// automatic text wrapping onto the next line
tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!");
// Test some print formatting functions
float fnumber = 123.45;
// Set the font colour to be blue with no background, set to font 4
tft.setTextColor(TFT_BLUE); tft.setTextFont(4);
tft.print("Float = "); tft.println(fnumber); // Print floating point number
tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
delay(10000);
}