⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd1602.c

📁 LCD1602的单片机驱动程序。。。希望对大家有用
💻 C
字号:
#include <reg52.h>
#include "lcd1602.h"

uchar code *time="time 19:20:30";

delayms(uint i)
{
 while(i--);
}

//写指令
void WriteCommand(uchar Command)
{
 E=0;
 RS=0;
 delayms(600);
 RW=0;
 delayms(600);
 LCDData=Command;
 delayms(600);
 E=1;
 E=0;
}
//写数据
void WriteData(uchar Data)
{
 delayms(900);
 E=0;
 RS=1;
 RW=0;
 LCDData=Data;
 E=1;
 E=0;
}
//在指定的位置写字符串
void WriteString(uchar Address,uchar *string)
{
 WriteCommand(Address); 
 while(!(*string=='\0'))
 {
  WriteData(*string);
  string++;
 }
}

//初始化1602液晶
void InitLCD1602()
{
 WriteCommand(0x38);
 delayms(200);
 WriteCommand(0x0f);
 delayms(200);
 WriteCommand(0x06);
 delayms(200);
 WriteCommand(0x01);
}


void main()
{
 InitLCD1602();
 WriteCommand(0x80);
 delayms(900);
 WriteData(0x31);
 WriteData(0x32);
 WriteData(0x34);
 WriteString(0x80,time);
 WriteCommand(0x8d);
 WriteData(0x38);
 while(1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -