ESP32 Hello World on LCD

Hi

How to add the Hello World to be seen on LCD ?

#include <SPI.h>
#include "LCD_Driver.h"
////////////////////////////



#define IMAGE_BACKGROUND    WHITE
#define FONT_FOREGROUND     BLACK
#define FONT_BACKGROUND     WHITE
////////////////////////////

// Set these to your desired credentials.

int LCD;
int ledblink = 2;


void setup()
{
  pinMode(ledblink, OUTPUT);
  Config_Init();
  LCD_Init();
  Serial.begin(115200);
  // WiFi.begin(ssid,password);
  LCD_SetBacklight(180);
  //  Paint_NewImage(LCD_WIDTH, LCD_HEIGHT, 90, WHITE);
  // Paint_SetRotate(90);
  //////////////////////////////////////////////////
  // LCD_Clear(0xffff); //white
  // LCD_Clear(0xF800); // red
  LCD_Clear(MAGENTA); //  
  // LCD_Clear(0x07E0);  // green
  // LCD_Clear(0x001F ); //blue
  //////////////////////////////////////////////////////////
  
}


void loop() {
  
    //  LCD_Write("Hello World!");
  //LCD.print("hello, world!");
  
  digitalWrite(ledblink, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(ledblink, LOW);   // turn the LED off by making the voltage LOW
  delay(100);

}

How does the Example code for the LCD library do it?

That is where I looked first when I did it. Details? In the example!

1 Like

Answers to the following questions would be helpful also:

  • Where did you get your LCD driver from?
  • Which type of LCD display are you using?
  • How did you wired it?
1 Like

Examples (for RPi) seem to be in this zip...
https://files.waveshare.com/upload/8/8d/LCD_Module_RPI_code.zip

This seems to be the library...

The hardware seems to be the WaveShare 1.8"

Thank you for your advice, problem solved.

Excellent. What steps did you take to solve this?

I contacted the supplier and they sent me the code.

Did the supplier send a link? WaveShare link?

No, they send me just code

Is it useful to show the solution to your topic?

#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h> // Or the specific library for your display
#include <SPI.h>
/*
    // Pin definitions for the display
    #define TFT_CS 10
    #define TFT_DC 7
    #define TFT_RST 8
    #define TFT_BL 9 // Backlight control
*/
//////////////
#define TFT_MOSI 23  // Data out
#define TFT_SCLK 18  // Clock out

#define TFT_CS   15// // Chip select pin
#define TFT_DC    2 // Data/Command pin
#define TFT_RST   4  // pin# 2
#define BL   32
//#define BL   -1
///////////////

// Initialize the TFT library with the correct pins and dimensions
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

void setup() {
  Serial.begin(115200); // Optional: for serial debugging
  Serial.println("Hello World!");
    pinMode(32, OUTPUT);
    digitalWrite(32, HIGH);
  // Initialize the display
  tft.init(170, 320); // Initialize with your screen dimensions
  //tft.setRotation(1); // 1 = HORIZONTAL,  Set screen rotation as needed (0, 1, 2, 3)
  tft.setRotation(3); // 3 = HORIZONTAL  upside down
  tft.fillScreen(ST77XX_BLUE);
  /*
    // Set text properties
    tft.setTextColor(ST77XX_WHITE);
    tft.setTextSize(2); // Set text size
    tft.setCursor(50, 150); // Set cursor position (x, y)

    // Print "Hello, World!"
    tft.println("Hello, World!");
  */
}

void loop() {
  // Set text properties
  tft.setTextColor(ST77XX_WHITE);
  tft.setTextSize(4); // Set text size
  tft.setCursor(0, 50); // Set cursor position (x, y)

  // Print "Hello, World!"
  tft.println("Hello, World!");
  // digitalWrite(32, HIGH);
  // delay(200);
  //digitalWrite(32, LOW);
}
1 Like

Aha, so the only difference from the code posted in the following thread:

is just the LCD backlight setting?

    pinMode(32, OUTPUT);
    digitalWrite(32, HIGH);

For the benefit of anyone experiencing similar issue, I recommend you clarifying the cause in the previous thread and this thread, and marking them as resolved.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.