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

📄 lcd1602.c

📁 keilC51驱动LCD1602,串口驱动.
💻 C
字号:
/*********************************************************************
	微 雪 电 子   WaveShare   http://www.waveShare.net	

目    的:   建立LCD1602的测试程序

目标系统:   基于任何兼容C51的微处理器

应用软件:   Keil C                                               

版    本:   Version 1.0

圆版时间:   2004-10-26

开发人员:   SEE

说    明:   若用于商业用途,请保留此段文字或注明代码来源

	深 圳 微 雪 电 子 保 留 所 有 的 版 权     
*********************************************************************/

/*01010101010101010101010101010101010101010101010101010101010101010101
----------------------------------------------------------------------
版本更新记录:
		版    本:   Version 1.1
		圆版时间:   2005-03-25
----------------------------------------------------------------------
接入模块: 
		LCD1602
接口说明: 
		短接以下端子:P35-RS,P36-RW,P37-E,P24-D4,P25-D5,P26-D6,P27-D7
----------------------------------------------------------------------
注意事项:
		* 操作LCD使用的IO口,该IO对应的LED-SW不得短接使能
		* 短接以下端子:P35-RS,P36-RW,P37-E,P24-D4,P25-D5,P26-D6,P27-D7
----------------------------------------------------------------------
10101010101010101010101010101010101010101010101010101010101010101010*/

#include <REGX51.H>
#include "D:\C51_H\CmmC51.H"

sbit LCD1602_RS		= P3^5;
sbit LCD1602_RW		= P3^6;
sbit LCD1602_E		= P3^7;
sbit LCD1602_D4		= P2^4;
sbit LCD1602_D5		= P2^5;
sbit LCD1602_D6		= P2^6;
sbit LCD1602_D7		= P2^7;
sbit LCD1602_BUSY	= P2^7;

#include "D:\C51_H\LCD1602.H"

sbit BUZZER = P1^0;
#define BUZ_ON  BUZZER = 0
#define BUZ_OFF BUZZER = 1

sbit USERLED = P1^1;
#define USERLED_ON  USERLED = 0
#define USERLED_OFF USERLED = 1

#define LED_P0RT P1

/*--------------------------------------------------------------------
函数全称:
函数功能:
注意事项:
提示说明:
输    入:	
返    回:
--------------------------------------------------------------------*/
void main()
{
    uint8 i;

	LCD1602_init();
	while(1)
	{
	
		LCD1602_setCmd("CLR_SCR");
		LCD1602_puts(0x82,"LCD1602 test");
		LCD1602_puts(0xc2,"waveShare.net");
	
		LCD1602_setCmd("LEFT_SCR");
		delay50ms(10);
		LCD1602_setCmd("LEFT_SCR");
		delay50ms(10);
		LCD1602_setCmd("RIGHT_SCR");
		delay50ms(10);
		LCD1602_setCmd("RIGHT_SCR");
		delay50ms(10);
		LCD1602_setCmd("LEFT_SCR");
		delay50ms(10);
		LCD1602_setCmd("LEFT_SCR");
		delay50ms(10);
		LCD1602_setCmd("RIGHT_SCR");
		delay50ms(10);
		LCD1602_setCmd("RIGHT_SCR");
		delay50ms(10);

		for(i=0;i<7;i++)
		{
			LED_P0RT <<= 1;
			delay50ms(20);
		}
	
		BUZ_ON;
		delay50ms(20);
		BUZ_OFF;
		delay50ms(20);
		BUZ_ON;
		delay50ms(20);
		BUZ_OFF;
		delay50ms(20);
	
		USERLED_ON;
		delay50ms(20);
		USERLED_OFF;
		delay50ms(20);
		USERLED_ON;
		delay50ms(20);
		USERLED_OFF;
		delay50ms(20);
	
		LED_P0RT=0x01;
		delay50ms(20);


	}

}

⌨️ 快捷键说明

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