【Proteus仿真】51单片机+LCD1602驱动显示模板程序

【Proteus仿真】51单片机+LCD1602驱动显示模板程序


  • Proteus仿真
    在这里插入图片描述

范例工程架构

在这里插入图片描述

LCD1602相关驱动显示函数

1
2
3
4
5
6
7
8
//函数或者变量声明
extern void LCD1602\_delay\_ms(unsigned int n);
extern void LCD1602\_write\_com(unsigned char com);
extern void LCD1602\_printc(unsigned char dat);//单字符显示
extern void LCD1602\_prints(unsigned char \*s);//字符串显示
extern void LCD1602\_Init();//初始化函数
extern void LCD1602\_set\_position(bit hang, unsigned char x);//指定位置显示

范例主程序代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <STC89C5xRC.H>
#include "LCD1602.h"


void main()
{
LCD1602\_Init(); //初始化LCD1602
LCD1602\_delay\_ms(1);
LCD1602\_set\_position(0,0);//指针设置到第一行第1列
LCD1602\_prints("Hello World!");
LCD1602\_set\_position(0,13);//指针设置到第一行第13列
LCD1602\_prints("STC");
// LCD1602\_write\_com(0x01); //清屏指令
while(1)
{
LCD1602\_set\_position(1,0); //指针设置到第二行第1列
LCD1602\_prints("perseverance");
LCD1602\_set\_position(1,14);//指针设置到第二行第14列
LCD1602\_prints("51");
}
}

范例工程模板和仿真资源

1
2
3
链接:https://pan.baidu.com/s/1bCG02Isi3-pLtcxfSOrIKg 
提取码:9ip5