Lesson 13 LCD1602

Share for us


In this lesson, we will learn how to use LCD1602 to display strings.


– 1*Raspberry Pi

– 1*Breadboard

– 1*Network cable (or USB wireless network adapter)

– 1*LCD1602

– 1*Potentiometer

– Jumper wires

Experimental Principle

LCD1602, also called character type LCD1602, is a dot matrix LCD module that specially used to display letters, figures, symbols, and so on. It consists of 16X2 dot matrixes, and each dot matrix is composed of 5X7 or 5X11 character bit. Each character bit can display a character. There is a dot space between each adjacent character bit. And there is a dot space between each row too. The dot space functions as a character space or a line space, and because of this, LCD1602 cannot display graphics very well. It is widely used in pocket instruments and low power application systems due to its micro power consumption, small size, rich contents display, ultra-thin and lightness.

LCD1602 use the standard 16-pin port, among which:

Pin 1(GND): connected to Ground;

Pin 2(Vcc): connected to 5V positive power supply;

Pin 3(Vo): used to adjust the contrast of LCD1602, lowest when connected to positive power supply, highest when connected to ground (you can connect a 10K potentiometer to adjust its contrast when using LCD1602);

Pin 4 (RS): A Register Selection pin, select data register when supplied high level (1), select instruction register when supplied low level (0);

Pin 5 (R/W): A Read/Write signal pin, read signals when supplied high level (1), write signals when supplied low level (0). Since we only need to write data to LCD1602, we directly connect this pin to ground;

Pin 6 (E): An Enable pin, when supplied low level, the LCD module will execute relevant instructions

Pin 7 (D0-D7)Pins that read and write data;                                              

A and K: LCD backlight power source;

LCD1602 has two operation modes: 4-bit mode and 8-bit mode. When the IOs of microprocessor (MCU) is nervous, you can choose 4-bit mode, which only use D4~D7 pins. After connecting the circuit, you can operate LCD1602 by Raspberry Pi.

Experimental Procedures

Step1: Connect the circuit as shown in the following diagram

Step 2: Edit and save the code (see path/Rpi_ ultraKit/13_lcd1602/lcd1602_python/ Adafruit_CharLCD.py )

 Step 3: Run the program


Now you can see two lines of characters displayed on the LCD1602. The first line is “SUNFOUNDER” and the second “Hello World!:)”.

Further Exploration

In this experiment, we drive LCD1602 in the 4-bit mode. You can also try to program by yourself to drive it in the 8-bit mode.


This lesson basically describes the principle and programming implementation for LCD1602 based on Raspberry Pi. You can further explore to create more interesting works with Raspberry Pi. Try now! 


#include <stdio.h>
#include <stdlib.h>

#include <wiringPi.h>
#include <lcd.h>

const unsigned char Buf[] = "---SUNFOUNDER---";

int main(void)
 int fd;
 int i;
 if(wiringPiSetup() == -1){
 fd = lcdInit(2, 16, 8,  11,10 , 0,1,2,3,4,5,6,7); //see /usr/local/include/lcd.h
 if (fd == -1){
  printf("lcdInit 1 failed\n") ;
  return 1;

 lcdPosition(fd, 0, 0);
 lcdPuts(fd, "  Raspberry Pi!");

 lcdPosition(fd, 0, 1);
 lcdPuts(fd, Buf);

   lcdPosition(fd, i, 1);
   lcdPutchar(fd, *(Buf+i));
  //lcdPosition(fd, 0, 1);
 return 0;