Control LCD

日本語のページ

You can control an LCD (character liquid crystal display) connected via I2C.
LCD-related blocks are in the "Display" - "LCD" group.

Connection

Connect the microcontroller and character LCD display via I2C.
If the microcontroller has fixed I2C SDA/SCL pins, use those fixed pins.
Also, use 5V power.

For example, when connecting to ESP32, connect as shown in the figure below.

Connection between ESP32 and LCD

Also, for microcontrollers where the I2C SDA/SCL pins are not fixed, specify the pin numbers to which the SDA/SCL are connected during initialization.

Initialization

For microcontrollers where the SDA/SCL pins are fixed, use the following initialization block.
Specify the number of characters/rows on the LCD and the I2C address.
Check the I2C address in advance using I2CScanner, etc.

Initialize LCD

Also, for microcontrollers where the SDA/SCL pins are not fixed, use the following initialization block to specify the pin numbers to which SDA/SCL are connected.

Initialize LCD while specifying SDA/SCL

Clear the display

To clear the LCD display, use the "Clear display" block.

Clear LCD

Displaying text

Before displaying text, specify the display position (cursor position) in the following block.
The top left corner of the screen is X=0/Y=0.

Set cursor position

Next, use a block to display the text.

Print string

Example

A 16 character/2 line LCD displays "Hello" at X=0/Y=0, and "World" at X=2/Y=1.
The display and clearing are repeated every second.
This example can be downloaded from here.

Example of displaying text on LCD