How To Connect LCD Display With I2C Module To Arduino

Table of contents:

How To Connect LCD Display With I2C Module To Arduino
How To Connect LCD Display With I2C Module To Arduino

Video: How To Connect LCD Display With I2C Module To Arduino

Video: How To Connect LCD Display With I2C Module To Arduino
Video: How to use LCD LCD1602 with I2C module for Arduino - Robojax 2024, April
Anonim

In the article, we will connect a 1602 liquid crystal display with an FC-113 I2C module to Arduino, due to which the connection will be carried out using only two data wires and two power wires.

LCD display with I2C adapter
LCD display with I2C adapter

It is necessary

  • - Arduino;
  • - LCD 1602 display (16 characters, 2 lines);
  • - I2C adapter FC-113;
  • - connecting wires.

Instructions

Step 1

The FC-113 module is based on the PCF8574T microcircuit, which is an 8-bit shift register - I / O expander for the I2C serial bus. In the figure, the microcircuit is designated DD1.

R1 is a trimming resistor for adjusting the contrast of the LCD.

Jumper J1 is used to turn on the display backlight.

Pins 1… 16 are used to connect the module to the LCD display pins.

Contact pads A1 … A3 are needed to change the address of the I2C device. By soldering the corresponding jumpers, you can change the device address. The table shows the correspondence of addresses and jumpers: "0" corresponds to the open circuit, "1" - to the installed jumper. By default, the device address is 0x27, i.e. all 3 jumpers are open.

FC-113 IIC device
FC-113 IIC device

Step 2

The module is connected to the Arduino as standard for the I2C bus: the SDA pin of the module is connected to the analog port A4, the SCL pin is connected to the analog port A5 of the Arduino. The module is powered by + 5V from the Arduino. The module itself is connected by pins 1 … 16 with the corresponding pins 1 … 16 on the LCD display.

Diagram of connecting I2C module FC-113 to LCD display and Arduino
Diagram of connecting I2C module FC-113 to LCD display and Arduino

Step 3

Now we need a library to work with LCDs via the I2C interface. You can use, for example, this one: https://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)#Sample_Code (link in the line "Download Sample code and library").

The downloaded archive "LiquidCrystal_I2Cv1-1.rar" is unzipped to the folder "\ libraries ", which is located in the Arduino IDE directory.

The library supports a set of standard functions for LCD screens:

LiquidCrystal () - creates a variable of type LiquidCrystal and accepts display connection parameters (pin numbers), begin () - initialization of the LCD display, setting parameters (number of lines and symbols);

clear () - clear the screen and return the cursor to the starting position;

home () - return the cursor to the starting position;

setCursor () - setting the cursor to the specified position;

write () - displays a character on the LCD screen;

print () - displays text on the LCD screen;

cursor () - shows the cursor, i.e. underline under the place of the next character;

noCursor () - hides the cursor;

blink () - cursor blinking;

noBlink () - cancel blinking;

noDisplay () - turn off the display while saving all displayed information;

display () - turn on the display while saving all displayed information;

scrollDisplayLeft () - scroll the display contents by 1 position to the left;

scrollDisplayRight () - scroll the display content 1 position to the right;

autoscroll () - enable autoscroll;

noAutoscroll () - turn off autoscroll;

leftToRight () - sets the direction of the text from left to right;

rightToLeft () - text direction from right to left;

createChar () - Creates a custom character for the LCD screen.

Installing the LiquidCrystal_I2C library
Installing the LiquidCrystal_I2C library

Step 4

Let's open the sample: File -> Samples -> LiquidCrystal_I2C -> CustomChars and redo it a bit. Let's display a message, at the end of which there will be a blinking symbol. All the nuances of the sketch are commented in the comments to the code.

Freehand sketch
Freehand sketch

Step 5

Let's take a closer look at the issue of creating your own symbols for LCD screens. Each character on the screen consists of 35 points: 5 wide and 7 high (+1 reserved underline). In line 6 of the above sketch, we set an array of 7 numbers: {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0}. Let's convert hex numbers to binary: {00000, 01010, 11111, 11111, 01110, 00100, 00000}. These numbers are nothing more than bit masks for each of the 7 lines of the character, where "0" denotes a light point, and "1" a dark point. For example, a heart symbol specified as a bit mask will appear on the screen as shown.

Creating your own symbols with a bitmask
Creating your own symbols with a bitmask

Step 6

Upload the sketch to Arduino. The screen will display the inscription we specified with a blinking cursor at the end.

Recommended: