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

📄 lcd.c

📁 基于51单片机的游戏
💻 C
字号:
#include <reg51.H>
#include <lcd.h>

char code int2charLCD[]="0123456789";
	
void write_LCD_command(unsigned command)
{
	rw=WRITE;
	rs=COMMAND;	  //写入指令寄存器
	enable=ENABLE;
	P1=command;
	delay100us(20);
	enable=DISABLE;
	rw=1;
}
void write_LCD_data(unsigned LCDdata)
{
	rw=WRITE;
	rs=DATA;//选择数据寄存器
	enable=ENABLE;
	P1=LCDdata;
	delay100us(20);
	enable=DISABLE;
	rw=1;
}
void init_LCD(void)
{
	write_LCD_command(TwoLine_8bit);// 0x38,数据以8位方式传送和接收,双行显示  	
	write_LCD_command(CURSOR_OFF);	// 0x0C,显示屏关闭,光标出现
	write_LCD_command(CURSOR_RIGHT);// 0x06,显示屏不移动,每次读入数据后,地址加1,光标右移一位
}
void clear_LCD()
{
	write_LCD_command(CLEAR);//清除显示器	
	write_LCD_command(CURSOR_HOME);//光标移到左上角	
}
void display_LCD_string(char *p) //显示字符串
{
	while(*p)
	{
		write_LCD_data(*p);
		p++;
	}
}
void display_LCD_number(char number) //显示一个数字
{
	unsigned char x,y;
	x=number;
//	y=number-10*x;
	write_LCD_data(int2charLCD[x]);
//	write_LCD_data(int2charLCD[y]);
}
void gotoxy(unsigned x,unsigned y)	 //设置光标到第Y行第X个字的位置
{
	if(x==1)  
		write_LCD_command(GOTO_LINE_1+y);
	else
    	write_LCD_command(GOTO_LINE_2+y);
}

⌨️ 快捷键说明

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