The single chip microcomputer adds a PCF8574 module to realize the IIC mode to drive LCD1602

Publisher:chaxue1987Latest update time:2019-10-21 Source: 51heiKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The PCF8574 module makes it possible to realize IIC driving LCD1602.


The following figure is the connection circuit diagram of PCF8574 module and 1602:


The actual connection method is as follows:

If you want to use the PCF8574 module to implement IIC driving LCD1602, it is very necessary to first understand the timing of IIC, PCF8574 device address, and four-line control LCD1602 method.

Below are two important h files. You can transplant them into your program by modifying some codes in these two h files (the wiring is different).

The microcontroller source program is as follows:

void delay1(uchar x)

{

        uchar a,b;

        for(a=x;a>0;a--)

         for(b=200;b>0;b--);

}


void write_com(uchar com) //write command function

{ uchar com1,com2;

        com1=com|0x0f;

        write_add(com1&0xfc);

        delay1(2);

    write_add(com1&0xf8);

        com2=com<<4;

        com2=com2|0x0f;

        write_add(com2&0xfc);

        delay1(2);

    write_add(com2&0xf8);

        

}


void write_date(uchar date) //Write data function

{

        uchar date1,date2;

        date1=date|0x0f;

        write_add(date1&0xfd);

        delay1(2);

        write_add(date1&0xf9);

        date2=date<<4;

        date2=date2|0x0f;

        write_add(date2&0xfd);

        delay1(2);

        write_add(date2&0xf9);

                

}


void init_lcd() //initialization function

{                                                                                                  

        write_com(0x33); //Display mode setting

        delayms(6);

        write_com(0x32); //Display mode setting

        delayms(6);

        write_com(0x28); //4-bit bus, double-line display, display 5×7 dot matrix characters

        delayms(6);

        write_com(0x01); //Clear screen

        delayms(6);

        write_com(0x06); //Character entry mode: screen does not move, characters move backward

        delayms(6);

        write_com(0x0c); //Display on and off cursor

        //write_LCD_Command(0x0f); //display on, cursor on, cursor blinking

        delayms(6);

}


//Display string: what is displayed in row x, column y

void ShowString(unsigned char x,unsigned char y,unsigned char *str)

{

        

        if(x == 1)

        {

                write_com(0x80 | y-1); 

        }

        if(x == 2)

        {

                write_com(0xc0 | y-1);

        }

        // Output string

        

        while(*str!='')

        {

                write_date(*str);

                str++;

        }


}


Keywords:MCU Reference address:The single chip microcomputer adds a PCF8574 module to realize the IIC mode to drive LCD1602

Previous article:Using 51 single chip microcomputer to control LCD12864 display screen source program
Next article:Single chip LCD12864 linked list to achieve the greedy snake source code

Recommended ReadingLatest update time:2024-11-22 23:44

Measurement of 51 microcontroller edge triggered interrupt response time
The MCS51 microcontroller series is an 8-bit microcontroller. It is a product launched by Intel in 1980 following the successful design of the MCS48 series. Because the MCS51 series has strong on-chip functions and command systems, it has made a leap forward in the application of microcontrollers. This series of produ
[Microcontroller]
The minimum system of STM8S microcontroller
The minimum system of STM8S microcontroller                                                          STM8S003F3P6 pin diagram   This is the pin diagram of the simplest STM8S003F3P6 in the STM8S series. Without using an external crystal oscillator, you only need to connect appropriate compon
[Microcontroller]
Dissimilar microcontrollers share external memory and methods of communicating with microcomputers
    Abstract: This paper introduces the method of realizing inter-board communication between the general microcontroller (MCU) AT89C51 and the signal processing microcontroller (DSP) TMS320C32 by sharing off-chip random access memory, and also provides the bus isolation hardware circuit and software control process.
[Industrial Control]
The working principle of microcontroller MSC1210 and the software and hardware design of CSR power control system
introduction MSC1210 is a highly integrated mixed-signal processing device produced by Texas Instruments (TI) in the United States. It integrates an enhanced 8051 core, 8-channel 24-bit high-precision delta-sigma A/D conversion, 21 interrupt sources, 16-bit PWM, full-duplex UART (and compatible with SPI function), 32K
[Microcontroller]
The working principle of microcontroller MSC1210 and the software and hardware design of CSR power control system
Design of MMS alarm system based on GPRS and single chip microcomputer
  The traditional domestic electronic anti-theft alarm system solution is often to detect theft and other alarm information through electronic equipment at the user end, and then automatically transmit the signal to the alarm center through the communicator via the telephone line to complete the alarm process. This ki
[Microcontroller]
Design of MMS alarm system based on GPRS and single chip microcomputer
[51 microcontroller STC89C52] ESP8266 ESP-01S module use
1. Some AT commands Note: AT command, control class check to send new lines, not required when transmitting data 2. Establish a TCP server Note: ESP-01S and the host must be in the same wifi network 3. Programming to implement device mode access router configuration 1. Programming analysis After ESP-01S conne
[Microcontroller]
[51 microcontroller STC89C52] ESP8266 ESP-01S module use
A design of OLED display based on single chip microcomputer
1 Introduction Organic electroluminescent display, also known as organic light emitting diode (OLED) or organic light emitting display (OLED), has obvious advantages over the popular liquid crystal display (LCD) on the market, mainly manifested in: self-luminescence (no backlight is required), no viewing angle probl
[Microcontroller]
A design of OLED display based on single chip microcomputer
Programming of outputting square wave pulse signal in T0 working mode of internal timer of single chip microcomputer
The internal timer T0 of the microcontroller works in mode 1, and a square wave pulse signal with a period of 2ms is output from P1.0. It is known that the crystal oscillator frequency of the microcontroller is 6MHZ. please (1) Calculate the time constant X using the formula X = 216 - t (f/12)  (2) Write a program lis
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号