1602 lcd module tutorial made in china

In this Step I cover four (4) animation examples: an animated Emoji, an animated arrow, an animated bouncing ball, going from left to right, and an animated bouncing ball in the same location on the LCD.

Of course, if the delay is reduced from its current setting of 1,500ms, as is appropriate for a tutorial - so changes can be seen, to a lesser value, the animation would move more quickly.

Below we design two (2) custom characters: a custom arrow and a blank character. That is, the first custom character designed is an arrow. The second is a blank character that will be used to remove each arrow after it is displayed. The custom arrow character is displayed in each of the sixteen (16) visible character positions on the second row, and then removed from each position it appears in. Here we use a 250 ms pause between consecutive arrow displays, to allow each arrow to be easily seen, as is appropriate for a tutorial.

Alternating ball characters are displayed in turn at every other one of the sixteen (16) visible character positions (i.e, first ball1 is displayed and then in the next position ball2) on the second row. These are then, subsequently, removed from each position the balls appear in. Here again, we delay 250 ms between displays, so each ball can be easily seen - as is appropriate for a tutorial. Any delay equal to or greater than 200 ms will also work.

Lastly, If we change the ball characters slightly, so they are even more visible, and write them to the same location, and shorten the delay. We bounce the ball, i.e., animate it, in the same LCD location.

1602 lcd module tutorial made in china

/* Demonstration sketch for PCF8574T I2C LCD Backpack Uses library from https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads GNU General Public License, version 3 (GPL-3.0) */

1602 lcd module tutorial made in china

Note: Microchip recently made some changes and their newer IDE versions use the XC8 compiler for Assembly, whereas all sample code here is created for the MPASM compiler. However, the sample code has been ported to XC8 by user tinyelect on our Discord channel (to whom we are extremely grateful!) and the XC8 version of the code is at the bottom of this tutorial for your reference. To see the changes needed to switch from MPASM to XC8, please check out the process that he shared.

Hi! This tutorial is going to be somewhat special - it will be the last one in this series. It’s been a long time since the very first tutorial and you’ve discovered a lot in the journey. And in conclusion, I want to show you how to work with the very popular character LCD with 2 lines, 16 characters each (usually just called the “1602 LCD”). This LCD comes with the in-built HD44780 driver (you can read more detail about it here). I will provide you brief information about it, the minimal amount required to initialize the display and show some text on it.

You can invent a lot of applications with these shift registers but now we will use this chip just as a tool to control the 1602 LCD. Let’s now consider it in more detail.

This LCD has the built-in character generator, so you don’t need to design your own characters (like we used to do with the 7-segment indicator). We can just send the ‘A’ letter to the display, and it will be shown - fascinating, isn’t it? Also, the display has 16 empty cells in which you can load your own characters and then use them but we won’t do this in this tutorial. The character generator of the LCDs from Aliexpress usually have a Chinese code page, so you can use the first 128 ASCII characters, which includes capital and small English letters, numbers, and the punctuation signs which is quite good!

RW is the read/write input. When it is low, the data goes from the microcontroller to the LCD, and when it is high, the data goes the reverse direction. As we don’t expect any data from the LCD, we can connect this pin to ground.

As for the commands that HD44780 uses, I will not describe them here. You can refer to the data sheet for full information. I will provide you with the information on how to initialize the display which you can use. Also, I’ll show you how to set the cursor position and display some data on the LCD.

The 1602 LCD (X2) is connected as described above. The Vo pin is connected to the 10-47 kOhm potentiometer R1. When you power up the device, you should rotate the handle of the potentiometer to make the rectangles of the LCD barely visible. Then the contrast level is set correctly. The LED+ pin is connected to VCC through the 22-47 Ohm resistor R2. The RS, E, D4, D5, D6, and D7 pins are connected to the shift register. Please pay attention that the data pins D4-D7 are connected to the lower four outputs of the shift register Q0-Q3, respectively. The RS input is connected to Q4, and E input is connected to Q5. Thus Q6 and Q7 pins remain unused, and you can expand your device with something else. The RW input of the LCD is connected to the GND, as we will just write to the LCD. The D0-D3 inputs remain unused in the 4-bit interface.

Now let’s consider the program that will initialize the LCD and write the “HELLO WORLD” message, where words will be located in the center of both lines of the LCD.

‘data_com’ is the auxiliary register, which has two values: 0 if we send command to the LCD, or 0x10 (‘1’ in the RS position, bit 4, see figure 4) if we send the data.

Finally, we define the control bits of the 1602 LCD (lines 16, 17) RS (bit 4) and E (bit 5), as these LCD pins are connected to the Q4 and Q5 of the shift register, correspondingly.

In lines 36-55 there is the LCD initialization part. As I said, just use it as is. There are different initialization sequences I’ve seen in the different sources, and this one is the minimum required that works. Let’s briefly consider this sequence.

First, we send the command 0x33 which prepares the LCD to work (lines 36, 37) by calling the ‘LCD_SEND’ subroutine which we will consider later. Then we perform the delay of 200 ms (lines 38, 39). Actually, the required delay is 1640 us but I decided not to add another delay subroutine, as we’re not in a rush.

As now we will transmit data, not a command, we need to set the ‘RS’ bit of the ‘data_com’ register to ‘1’ (line 60). And then we just consecutively send five characters: H, E, L, L, O (lines 62-71), and they will be displayed on the LCD, nothing else is required.

Now let’s see how to send data to the LCD. As I mentioned before, the data byte is split into two nibbles as we use the 4-bit interface. Also, we will need to send each nibble twice: first time with the E = 1 to start the pulse on the E input, and the second time the same nibble but with E = 0 to finish the pulse. So in total, we need to send 4 bytes to the shift register to transmit a single byte to the LCD. And now let’s return to the program code.

First, we copy the byte which we need to send from the W register into the ‘lcd_data’ register (line 113) and into the ‘data_byte’ register (line 114). Then we swap the ‘data_byte’ register to have the upper nibble in the lower four bits (line 115) as we have to send the upper nibble first. Then we perform the AND operation between the ‘data_byte’ and the 0x0F to clear the upper nibble (lines 116, 117).

Now we have the upper nibble of the ‘lcd_data’ in the lower four bits of the ‘data_byte’ and after coming through the shift register it will appear on the Q3-Q0 outputs and get to the D7-D4 inputs of the display, respectively. We need to take care of the RS and E signals now.

Then we send the lower nibble of the ‘lcd_data’ (lines 129-144) which is almost the same as sending the upper nibble except for not swapping the nibbles in the beginning.

So assemble the device according to the schematics diagram (figure 4), compile the program, and connect your PICkit to the PC. disconnect the DS and CTCP pins of the shift register from the MCU and flash it. Then disconnect the programming wires and connect the DS and CTCP wires again. If you did it within 2 seconds, you will see the text “HELLO WORLD” on your LCD, otherwise power off then power on your device and enjoy its greeting to you. If you don’t see the text even now, rotate the potentiometer handle to set the contrast, this should help. If you still don’t see anything then check the connections: there are a lot of wires in this device and it’s easy to mess up.

Now, some traditional statistics. We’ve learnt how to work with the shift register 74HC595, also we’ve discovered how to use the 1602 LCD with the HD44780 driver. As for the PIC10F200 commands, we haven’t learnt any new one this time. The code length is just 118 words so there is a lot of free space to add some more functionality.

As this is the last tutorial regarding the PIC10F200 programming, I feel like I have to tell you about the instructions we haven’t used yet. Maybe you will find them useful in some cases.CLRWDT is a very specific instruction that is used to clear the watchdog timer if it’s enabled. It doesn’t have any operands and is used standalone.

I think I need to say something encouraging here. We’ve passed a long way since our first program in the assembly language which was only able to light up an LED. And now you see how we’ve grown up. We have discovered how to use the most widespread digital interfaces, how to deal with analog signals with a microcontroller which doesn’t have this ability. Such things make you think outside the box, make you invent how to do things that look impossible at first sight. I hope this series will encourage somebody to keep learning the microcontrollers. You will see that a lot of things that we’ve done here can be done easier with hardware modules but as I mentioned several times, this series is for those who want to know what’s hidden inside.

1602 lcd module tutorial made in china

Hi again! In this tutorial we will not discover any new MCU modules. Instead we will learn how to use the 1602 character LCD with the HD44780 driver. If you read the PIC10F200 tutorials, you should already be familiar with it. But that time I talked about it superficially, and now I will tell you about it in more detail. If you read the previous tutorial, you still can find something interesting here as I will show another programming approach of communication between the LCD and the MCU.

The task for today is still the same as in tutorial 18. As is customary in programming, we need to write the text “Hello world ☻” on the LCD. The “smiley” character should be generated manually and loaded into the Character Generator memory.

This LCD has the built-in character generator, so you don’t need to design your own characters (like we had to with the 7-segment indicator). We can just send the ‘A’ letter to the display, and it will be shown - fascinating, isn’t it? Also, the display has 16 empty cells in which you can load your own characters and then use them (I will talk about it later). The character generator of the LCDs from Aliexpress usually have a Chinese code page, so you can use the first 128 ASCII characters, which includes capital and small English letters, numbers, and punctuation signs which is quite good!

RW is the read/write input. When it is low, the data goes from the microcontroller to the LCD, and when it is high, the data goes the reverse direction. As we don’t expect any data from the LCD, we can connect this pin directly to ground.

As for the commands that the HD44780 uses, we didn’t consider them previously but now we will consider them in detail. I will base my explanations on the data sheet of the HD44780 driver, so you also can refer to it for full information. Let me present to table 6 from the data sheet (Figure 3) where all the LCD commands are described.

As you can see in Figure 3, the LCD has quite few commands, and each of them has at least one “1” in the data bits. Let me briefly run over all commands.“Clear display” command (0x01) seems to be quite clear (pun definitely intended): it clears the display content and sets the DDRAM counter to 0, so after this, the next character will be printed in the first position of the first line.

F (bit #2) sets the character font type: 0 for 5x8, 1 for 5x10. This parameter should be set according to the physical LCD type. The most widespread displays have the 5x8 characters, so we need to set this bit as 0.

“Set DDRAM address” (0x80) sets the address of the display data memory. This address has 7 bits width, and sets the position of the cursor at the LCD. Bit #6 sets the line number (0 – first line, 1 – second line), and bits #3-0 set the position within a line (0 to 15).

This schematic diagram consists of the PIC18F14K50 MCU (DD1), PICKit debugger (X1), and the 1602 LCD (X2) which is connected as described above. The Vo pin is connected to the 10-47 kOhm potentiometer R1. When you power up the device, you should rotate the handle of the potentiometer to make the rectangles of the LCD barely visible. Then the contrast level is set correctly. The LED+ pin is connected to VCC through the 22-47 Ohm resistor R2. The RS, E, D4, D5, D6, and D7 pins are connected to the MCU. The data pins D4-D7 are connected to the pins RC0-RC3, respectively. The RS input is connected to RC4, and E input is connected to RC5. The RW input of the LCD is connected to GND, as we will just write to the LCD. The D0-D3 inputs remain unused in the 4-bit interface.

In this project we will only use the Pin Module and the System Module. The configuration is very simple and doesn’t require additional explanation (Figure 6-7).

In the System Module we set the CPU frequency as 32 MHz and disable the Low-voltage programming. In the Pin Module we configure pins to which the LCD is connected (see Figure 5) as outputs and give them the corresponding custom name.

In this project we also will use the concept of distributing the code between different files like we did in tutorial 15. So we will create special files where we will write all the LCD-related code.

We need to create two new files: one “main.c…” and one “xc8_header.h…”, and call them both “lcd_1602_mcc” (see tutorial 15 for more details on how to do this).

Thelcd_send function (line 3) allows sending the data byte to the LCD via a 4-bit interface. It has two parameters: value, which represents the byte that will be sent to the LCD, and rs which represents the state of the RS pin: 0 for low or 1 for high.

The lcd_data function (line 5) sends the character byte to the LCD, which is defined with thedata parameter. This character will be sent either to CGRAM or to DDRAM.

Thelcd_init function (line 6) initializes the LCD with the 4-bit interface. It has two parameters: cursor which shows (when it is 1) or hides (when it is 0) the cursor, and blink which enables (when it is 1) or disables (when it is 0) the blinking of the cursor position.

The lcd_create_char function (line 9) creates one character in the CGRAM memory at the address defined by the addr parameter. Parameter data is the array of 8 bytes that define the character.

First, we include the “mcc.h” header file (line 1) to use the MCC-generated functions in the current file. Then we include the “lcd_1602_mcc.h” file (line 2). Actually we don’t necessarily need to include it because we don’t use any definitions from that header in the current file. The rest of the file contains the functions code.

Let’s begin with the function lcd_send (lines 4-50). This is the most important function here and it implements the low-level communication between the MCU and LCD. To understand better how it works, let’s consider the part of the timing diagram from the figure 9 of the datasheet that corresponds to the writing cycle (Figure 8).

Now we need to send the upper nibble of the value via the pins D4-D7. We will do this bit by bit. This is a different approach than in the previous tutorial but it gives more flexibility because it doesn’t require all data pins of the LCD to be connected to the consequent pins of the same port of the MCU.

In line 27, we perform the short delay of 1us which is needed by the LCD driver. Actually the minimal length of the E pulse is 230 ns according to the data sheet, but as we’re not going to display dynamic information, 1 us is fine.

After that, we consider that the 8 bits of the data byte are sent to the LCD. Finally, we implement the 40us delay to complete the operation (line 49). According to the HD44780 driver data sheet the time of execution of most commands is 37us. So 40us is plenty of time for it to execute most of the commands. For the commands that need more execution time we will implement the additional delay beyond this function.

The lcd_command (lines 52-55) and lcd_data (lines 57-60) functions are very similar: they both consist of one line, in which the lcd_send function is invoked (lines 54 and 59). But in the lcd_command function the rs parameter is 0, and in the lcd_data function the rs parameter is 1. We could get rid of these functions and replace them with the lcd_send, which could do both functions, but using them makes the code more readable.

The lcd_init function (lines 62-73) initializes the LCD according to the routine suggested in Figure 24 of the datasheet of the HD44780 driver but with slight changes.

In lines 75-83 there is the lcd_write function. It displays the string ‘s’ in the LCD. The parameter s should be the c-type string with a terminating zero. This means that the string should end with the “0” character, which is the sign of the end of the line. This puts certain limitations, because we can’t display the character which is located at address 0 of the DDRAM but we can send it separately using the lcd_data function.

So, in line 77 we declare the variable iand assign its value as 0. This is the counter of the characters in the string. In line 78 we start the while loop which will be implemented while the current character is not 0. The content of the loop is quite simple. First, we send the current character to the LCD (line 80), and then we increment the character counter i (line 81).

In lines 85-92 there is the lcd_set_cursor function. In this function we consider that the first cursor position has the coordinates [1;1] but as the physical coordinates inside the display start with 0, we will need to subtract 1 from each parameter.

The last function, lcd_create_char, is located in lines 94-103. In this function we also first check if the address is bigger than 7 (line 96) and set it as 7 in this case (line 97). This is needed because there are only eight available custom characters with addresses 0 to 7.

In line 98, we send the “Set CGRAM address” command, in which we shift the addr parameter 3 bits to the left. This is needed because the last 3 bits set the line address within one character (see Figure 4). After that, we implement the for loop (line 99) inside which we send the 8 bytes to the LCD which will form the required character (line 101).

And that are all functions that are required for operation with the LCD in the current and following projects. Please save these two files, we will copy-paste them to other projects as well.

As you can see, the program is very short. This is because the majority of the code was written in previously described files. In line 2 we include the “lcd_1602_mcc.h” file to use the LCD-related functions.

In lines 6-19 there is the main function of the program. In lines 11-16 there are functions related to the LCD. In line 11, we initialize the LCD without the cursor or blinking. In line 12, we create a new character at address 1 using the array smile. In line 13, we set the cursor at the sixth position of the first line, and then write the text “Hello” in it (line 14). In line 15, we set the cursor at the fifth position of the second line, and then write the text “world ☻” there (line 16). Pay attention to the expression “\1” in the text. The backslash symbol makes the next character in the string the special one. For example “\n” means the new line, “\r” means carriage return, “\”” means the quote sign, etc. If the number follows the backslash, this means that we want to print the character with the address defined by this number. So the expression “\1” means the character at the address 1, which is the smiley that we defined in line 4.

So assemble the device according to the schematics diagram (Figure 5), compile the program, and connect your PICkit to the PC. Configure the PICkit voltage according to your LCD type (5V or 3.3V) and run the program. You should see the text “Hello world ☻” on your LCD. If you don’t see the text even now, rotate the potentiometer handle to set the contrast, this should help. If you still don’t see anything then check the connections: there are a lot of wires in this device and it’s easy to mess up.

1602 lcd module tutorial made in china

Do you want your Arduino projects to display status messages or sensor readings? Then these LCD displays can be a perfect fit. They are extremely common and fast way to add a readable interface to your project.

This tutorial will help you get up and running with not only 16×2 Character LCD, but any Character LCD (16×4, 16×1, 20×4 etc.) that is based on Hitachi’s LCD Controller Chip – HD44780.

True to their name, these LCDs are ideal for displaying only text/characters. A 16×2 character LCD, for example, has an LED backlight and can display 32 ASCII characters in two rows of 16 characters each.

The good news is that all of these displays are ‘swappable’, which means if you build your project with one you can just unplug it and use another size/color LCD of your choice. Your code will have to change a bit but at least the wiring remains the same!

Vo (LCD Contrast) controls the contrast and brightness of the LCD. Using a simple voltage divider with a potentiometer, we can make fine adjustments to the contrast.

RS (Register Select) pin is set to LOW when sending commands to the LCD (such as setting the cursor to a specific location, clearing the display, etc.) and HIGH when sending data to the LCD. Basically this pin is used to separate the command from the data.

R/W (Read/Write) pin allows you to read data from the LCD or write data to the LCD. Since we are only using this LCD as an output device, we are going to set this pin LOW. This forces it into WRITE mode.

E (Enable) pin is used to enable the display. When this pin is set to LOW, the LCD does not care what is happening on the R/W, RS, and data bus lines. When this pin is set to HIGH, the LCD processes the incoming data.

Now we will power the LCD. The LCD has two separate power connections; One for the LCD (pin 1 and pin 2) and the other for the LCD backlight (pin 15 and pin 16). Connect pins 1 and 16 of the LCD to GND and 2 and 15 to 5V.

Most LCDs have a built-in series resistor for the LED backlight. You’ll find this near pin 15 on the back of the LCD. If your LCD does not include such a resistor or you are not sure if your LCD has one, you will need to add one between 5V and pin 15. It is safe to use a 220 ohm resistor, although a value this high may make the backlight a bit dim. For better results you can check the datasheet for maximum backlight current and select a suitable resistor value.

Next we will make the connection for pin 3 on the LCD which controls the contrast and brightness of the display. To adjust the contrast we will connect a 10K potentiometer between 5V and GND and connect the potentiometer’s center pin (wiper) to pin 3 on the LCD.

That’s it. Now turn on the Arduino. You will see the backlight lit up. Now as you turn the knob on the potentiometer, you will start to see the first row of rectangles. If that happens, Congratulations! Your LCD is working fine.

Let’s finish connecting the LCD to the Arduino. We have already made the connections to power the LCD, now all we have to do is make the necessary connections for communication.

We know that there are 8 data pins that carry data to the display. However, HD44780 based LCDs are designed in such a way that we can communicate with the LCD using only 4 data pins (4-bit mode) instead of 8 (8-bit mode). This saves us 4 pins!

The sketch begins by including the LiquidCrystal library. The Arduino community has a library called LiquidCrystal which makes programming of LCD modules less difficult. You can find more information about the library on Arduino’s official website.

First we create a LiquidCrystal object. This object uses 6 parameters and specifies which Arduino pins are connected to the LCD’s RS, EN, and four data pins.

In the ‘setup’ we call two functions. The first function is begin(). It is used to specify the dimensions (number of columns and rows) of the display. If you are using a 16×2 character LCD, pass the 16 and 2; If you’re using a 20×4 LCD, pass 20 and 4. You got the point!

After that we set the cursor position to the second row by calling the function setCursor(). The cursor position specifies the location where you want the new text to be displayed on the LCD. The upper left corner is assumed to be col=0, row=0.

There are some useful functions you can use with LiquidCrystal objects. Some of them are listed below:lcd.home() function is used to position the cursor in the upper-left of the LCD without clearing the display.

lcd.scrollDisplayRight() function scrolls the contents of the display one space to the right. If you want the text to scroll continuously, you have to use this function inside a for loop.

lcd.scrollDisplayLeft() function scrolls the contents of the display one space to the left. Similar to above function, use this inside a for loop for continuous scrolling.

If you find the characters on the display dull and boring, you can create your own custom characters (glyphs) and symbols for your LCD. They are extremely useful when you want to display a character that is not part of the standard ASCII character set.

As discussed earlier in this tutorial a character is made up of a 5×8 pixel matrix, so you need to define your custom character within that matrix. You can use the createChar() function to define a character.

CGROM is used to store all permanent fonts that are displayed using their ASCII codes. For example, if we send 0x41 to the LCD, the letter ‘A’ will be printed on the display.

CGRAM is another memory used to store user defined characters. This RAM is limited to 64 bytes. For a 5×8 pixel based LCD, only 8 user-defined characters can be stored in CGRAM. And for 5×10 pixel based LCD only 4 user-defined characters can be stored.

1602 lcd module tutorial made in china

Overhere we will show you what is the I2C LCD 1602 Display and how it works, you can follow the next lesson to get how to use the I2C LCD 1602 Display with the micro bit.

The integration of an LCD display greatly facilitates the interactivity of the project you are developing, allowing the user to directly read some output parameters. These values can be either a simple text or numerical values read by the sensors, such as temperature or pressure, or even the number of cycles that the Arduino is performing.

The LCD1602 display has an integrated microchip that manages this type of communication, and then all of the input and output information are limited to only two PINs (excluding power supply). I2C is a type of serial bus developed by Philips, which uses two bidirectional lines, called SDA (Serial Data Line) and SCL (Serial Clock Line). Both must be connected via pulled-up resistors. The usage voltages are standard as 5V and 3.3V.

The blue potentiometer on the I2C LCD1602 (see the figure below) is used to adjust the backlight  for better display.And there is a jumper on the board, if you take away this jumper , the backlight will aways be off.

Because the output power of the micro bit is limited, please connect the USB cable to the USB port on the micro bit when downloading the program. After the program is successfully downloaded to the board, connect the USB cable to the USB port on the expansion board, ensure the LCD display can work perfectly.

After downloaded this code to your micro bit, pull out the USB line and insert the USB line to the expansion board, you will see “OSOYOO”,”Hello” on the LCD screen, then the entire screen will be full of random numbers.

1602 lcd module tutorial made in china

Connecting an LCD to your Raspberry Pi will spice up almost any project, but what if your pins are tied up with connections to other modules? No problem, just connect your LCD with I2C, it only uses two pins (well, four if you count the ground and power).

In this tutorial, I’ll show you everything you need to set up an LCD using I2C, but if you want to learn more about I2C and the details of how it works, check out our article Basics of the I2C Communication Protocol.

BONUS: I made a quick start guide for this tutorial that you can download and go back to later if you can’t set this up right now. It covers all of the steps, diagrams, and code you need to get started.

There are a couple ways to use I2C to connect an LCD to the Raspberry Pi. The simplest is to get an LCD with an I2C backpack. But the hardcore DIY way is to use a standard HD44780 LCD and connect it to the Pi via a chip called the PCF8574.

The PCF8574 converts the I2C signal sent from the Pi into a parallel signal that can be used by the LCD. Most I2C LCDs use the PCF8574 anyway. I’ll explain how to connect it both ways in a minute.

I’ll also show you how to program the LCD using Python, and provide examples for how to print and position the text, clear the screen, scroll text, print data from a sensor, print the date and time, and print the IP address of your Pi.

Connecting an LCD with an I2C backpack is pretty self-explanatory. Connect the SDA pin on the Pi to the SDA pin on the LCD, and the SCL pin on the Pi to the SCL pin on the LCD. The ground and Vcc pins will also need to be connected. Most LCDs can operate with 3.3V, but they’re meant to be run on 5V, so connect it to the 5V pin of the Pi if possible.

If you have an LCD without I2C and have a PCF8574 chip lying around, you can use it to connect your LCD with a little extra wiring. The PCF8574 is an 8 bit I/O expander which converts a parallel signal into I2C and vice-versa. The Raspberry Pi sends data to the PCF8574 via I2C. The PCF8574 then converts the I2C signal into a 4 bit parallel signal, which is relayed to the LCD.

Before we get into the programming, we need to make sure the I2C module is enabled on the Pi and install a couple tools that will make it easier to use I2C.

Now we need to install a program called I2C-tools, which will tell us the I2C address of the LCD when it’s connected to the Pi. So at the command prompt, enter sudo apt-get install i2c-tools.

Now reboot the Pi and log in again. With your LCD connected, enter i2cdetect -y 1 at the command prompt. This will show you a table of addresses for each I2C device connected to your Pi:

We’ll be using Python to program the LCD, so if this is your first time writing/running a Python program, you may want to check out How to Write and Run a Python Program on the Raspberry Pi before proceeding.

The function mylcd.lcd_display_string() prints text to the screen and also lets you chose where to position it. The function is used as mylcd.lcd_display_string("TEXT TO PRINT", ROW, COLUMN). For example, the following code prints “Hello World!” to row 2, column 3:

On a 16×2 LCD, the rows are numbered 1 – 2, while the columns are numbered 0 – 15. So to print “Hello World!” at the first column of the top row, you would use mylcd.lcd_display_string("Hello World!", 1, 0).

You can create any pattern you want and print it to the display as a custom character. Each character is an array of 5 x 8 pixels. Up to 8 custom characters can be defined and stored in the LCD’s memory. This custom character generator will help you create the bit array needed to define the characters in the LCD memory.

The code below will display data from a DHT11 temperature and humidity sensor. Follow this tutorial for instructions on how to set up the DHT11 on the Raspberry Pi. The DHT11 signal pin is connected to BCM pin 4 (physical pin 7 of the RPi).

By inserting the variable from your sensor into the mylcd.lcd_display_string() function (line 22 in the code above) you can print the sensor data just like any other text string.

These programs are just basic examples of ways you can control text on your LCD. Try changing things around and combining the code to get some interesting effects. For example, you can make some fun animations by scrolling with custom characters. Don’t have enough screen space to output all of your sensor data? Just print and clear each reading for a couple seconds in a loop.

1602 lcd module tutorial made in china

In this tutorial, we will learn how to make custom characters on an I2C LCD display. Click hereto refer to my previous blog and learn about the I2C LCD display basics. Custom characters are non-original figures created from original parts. You can create different figures such as hearts, squares, rectangles, and more.

The I2C LCD display is made up of blocks which are fundamentally 5 dots in a row and 8 dots in a column. The LCD has 32 of those blocks and it makes up the 16X2 LCD. You can program each of the blocks to make any figure you want.

The picture above shows the organization of a single block that is used to make up LCD. To create a custom character, we need to define which dot out of the 5 x 8 block has to be lighted up. This can be done by writing the binary equivalent of each row and column. Each dot is either on or off. We can create figures by turning them off or on. Use this website below to get the understanding on create figures.

The program is pretty simple. We are declaring the variable smileyFace which is array of type byte. This array will contain 8 bytes, one for each row in our block. The block is made up by 5X8 dots as mentioned before.We can program those dots by turning them on or off. In this code we write 0 for off and 1 is for on. Writing that, you can create any figure you want! In setup function, we simply turn on the background light of the LCD. Then, we set the cursor to the place you want to display your text, and display it by using the setCursor function of the library.

1602 lcd module tutorial made in china

With the TFT display you can display colorful images or graphics. This module has a resolution of 480 x 320. This module includes the SD card socket and SPI FLASH circuit.

1602 lcd module tutorial made in china

Character display module is an LCD module with a certain number of rows and columns, and has a green or blue backlight and white character. These displays can usually be used to display text, characters and numbers. The contrast can be adjusted by connecting a potentiometer to pin 3. Pin 15 and 16 are for backlight. You can use 6 pins E, RS, DB4, DB5, DB6, DB7 to interface the display with Arduino.

1602 lcd module tutorial made in china

In the previous chapter, we have discussed how a character LCD is interfaced with a PIC microcontroller in 8-bit mode, where we used predefined characters stored in the LCD to display our data. In this article, we will learn more about the LCD and how we can create and use custom characters.

For making custom patterns we need to write values to the CGRAM area defining which pixel to glow. These values are to be written in the CGRAM address starting from 0x40. CGRAM has a total of 64 Bytes. For LCD using 8×5 dots for each character, you can define a total of 8 user defined patterns (1 Byte for each row and 8 rows for each pattern).

Custom characters are assigned fixed display codes from 0 to 7 for pattern stored in the location pointed by CGRAM address 0x40, 0x48, 0x56… and so on. So, if the user wants to display second pattern (pattern stored at CGRAM address 0x48), simply call the data function with value 1 as an argument at a desired location in the LCD.

To display the sequence in the LCD, we need to specify the position on LCD and which pattern to display at the position. Provide adequate delay in between frames to observe the sequence distinctly.

1602 lcd module tutorial made in china

Nowadays most popular microcontrollers are working on 3.3V but many liquid crystal displays (LCDs) for them are usually on 5V, because they are centered on Hitachi’s de facto standard LCD controller – the HD44780 chip. Presented here is a simple yet effective trick to convert the standard 5V type LCD to a 3.3V one!

As you can see in the following photo some LCD modules have unpopulated footprints on the back for mounting a switched-capacitor voltage converter like the L7660 or MAX660 IC. Incase you have the same LCD circuit board, just add one MAX660 chip (U3),and two 10uF capacitors (C1-C2) to complete the hack. However, don’t forget to open the jumper J1 and close J3. That’s all.

This little modification adds a negative charge pump converter to feed negative contrast voltage(V0) around 2.5V to the display electronics. This hack is necessary because the characters on the liquid crystal display type mentioned here becomes visible only when VDD-V0 ≥ 5V, where VDD is the operating voltage, and V0 is the contrast voltage of the LCD. Our simple maths gives an output value of V0 ≈ -2V, good for proper operation of the LCD at 3.3V. Take note, here the backlight lamp works as well on 3.3V, its brightness is slightly lower. This can be corrected by changing the value of its onboard current-limiter resistor (R8) if necessary.

Another issue for concern (often when interfacing with fast microcontrollers) is the oscillator frequency of the LCD electronics, ie. when the supply voltage is lowered (5V to 3.3V), frequency of the built-in clock oscillator also falls down. The Rosc should be changed to a suitable value (from the typical 91KΩ – see next figure) for 3.3V if the extension of command execution time cannot be accepted.

Even if your LCD is a different type i.e. without the vacant solder pads, you can still convert it to a 3.3V type with the help of the L7660 chip. For this, just build the following circuit on a small veroboard (or a customized pcb), and carefully interface it to your 5V LCD. However, your 5V LCD should be a type with HD44780 (or compatible) controller at its heart. The potentiometer (P1) in the given circuit is for contrast level adjustment of the display.

While I was in the middle of my experiments, I got another 16×2 (5V) LCD module from a friend abroad (see next photo). It has the provision to mount L7660 chip (suits our needs) but we need to populate some more resistors/jumpers in addition to the usual 10uFx2 capacitors (see the marked area). Now I’m surfing the internet to get it running on 3.3V – stay tuned for updates…

1602 lcd module tutorial made in china

A few weeks ago, we examined the features of ESP32 module and built a simple hello world program to get ourselves familiar with the board. Today, we will continue our exploration of the ESP32 on a higher level as we will look at how to interface a 16×2 LCD with it.

Displays provide a fantastic way of providing feedback to users of any project and with the 16×2 LCD being one of the most popular displays among makers, and engineers, its probably the right way to start our exploration. For today’s tutorial, we will use an I2C based 16×2 LCD display because of the easy wiring it requires. It uses only four pins unlike the other versions of the display that requires at least 7 pins connected to the microcontroller board.

ESP32 comes in a module form, just like its predecessor, the ESP-12e, as a breakout board is usually needed to use the module. Thus when it’s going to be used in applications without a custom PCB, it is easier to use one of the development boards based on it. For today’s tutorial, we will use the DOIT ESP32 DevKit V1 which is one of the most popular ESP32 development boards.

The schematics for this project is relatively simple since we are connecting just the LCD to the DOIT Devkit v1. Since we are using I2C for communication, we will connect the pins of the LCD to the I2C pins of the DevKit. Connect the components as shown below.

Due to the power requirements of the LCD, it may not be bright enough when connected to the 3.3v pin of the ESP32. If that is the case, connect the VCC pin of the LCD to the Vin Pin of the ESP32 so it can draw power directly from the connected power source.

At this point, it is important to note that a special setup is required to enable you to use the Arduino IDE to program ESP32 based boards. We covered this in the introduction to ESP32 tutorial published a few weeks go. So, be sure to check it out.

To be able to easily write the code to interact with the I2C LCD display, we will use the I2C LCD library. The Library possesses functions and commands that make addressing the LCD easy. Download the I2C LCD library from the link attached and install on the Arduino IDE by simply extracting it into the Arduino’s library folder.

Before writing the code for the project, it’s important for us to know the I2C address of the LCD as we will be unable to talk to the display without it.

While some of the LCDs come with the address indicated on it or provided by the seller, in cases where this is not available, you can determine the address by using a simple sketch that sniffs the I2C line to detect what devices are connected alongside their address. This sketch is also a good way to test the correctness of your wiring or to determine if the LCD is working properly.

If you keep getting “no devices found”, it might help to take a look at the connections to be sure you didn’t mix things up and you could also go ahead and try 0x27 as the I2C address. This is a common address for most I2C LCD modules from China.

Our task for today’s tutorial is to display both static and scrolling text on the LCD, and to achieve that, we will use the I2C LCD library to reduce the amount of code we need to write. We will write two separate sketches; one to displaystatic textsand the other to display both static and scrolling text.

To start with the sketch for static text display, we start the code by including the library to be used for it, which in this case, is the I2C LCD library.

Next, we create an instance of the I2C LCD library class with the address of the display, the number of columns the display has (16 in this case), and the number of rows (2 in this case) as arguments.

With that done, we proceed to the void setup() function. Here we initialize the display and issue the command to turn the backlight on as it might be off by default depending on the LCD.

Next is the void loop() function. The idea behind the code for the loop is simple, we start by setting the cursor to the column and row of the display where we want the text to start from, and we proceed to display the text using the lcd.print() function. To allow the text to stay on the screen for a while (so its visible) before the loop is reloaded, we delay the code execution for 1000ms.

For the scrolling text, we will use some code developed by Rui Santos of RandomNerdTutorials.com. This code allows the display of static text on the first row and scrolling text on the second row of the display at the same time.

Next, we create an instance of the I2C LCD library class with the address of the display, the number of columns the display has (16 in this case), and the number of rows (2 in this case) as arguments.

Next, we create the function to display scrolling text. The function accepts four arguments; the row on which to display the scrolling text, the text to be displayed, the delay time between the shifting of characters, and the number of columns of the LCD.

That’s it for today’s tutorial guys. Thanks for following this tutorial. This cheap LCD display provides a nice way of providing visual feedback for your project and even though the size of the screen and the quality of the display is limited, with the scrolling function you can increase the amount of text/characters that can be displayed.