单片机控制12864液晶显示屏显示静态图片

12864介绍

介绍

PROTEUS仿真电路图:

在这里插入图片描述

仿真结果展示:

大长安城墙的一角:
在这里插入图片描述
大雁塔:
在这里插入图片描述
龙:
在这里插入图片描述

C语言程序代码:

#include <reg51.h>

#define LCDLCDDisp_Off   0x3e
#define LCDLCDDisp_On    0x3f
#define Page_Add     0xb8//ye

#define LCDCol_Add     0x40//lie
#define Start_Line     0xC0//hang
/*****液晶显示器的端口定义*****/
#define data_ora P1 /*液晶数据总线*/
sbit LCDMcs=P2^4 ;    /*片选1*/
sbit LCDScs=P2^3 ;    /*片选2*/
sbit LCDDi=P2^2 ;     /*数据/指令 选择*/
sbit LCDRW=P2^1 ;     /*读/写 选择*/
sbit LCDEnable=P2^0 ;     /*读/写 使能*/



char code Hz[]=
{

    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x20,0x28,0x38,0x38,0x18,0x00,
      0x08,0x08,0x08,0x04,0x04,0x04,0x04,0x84,0xC8,0x78,0x30,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x80,0xC0,0x40,0x00,0x80,0x80,0x80,0x00,0x00,
      0xC0,0x80,0x00,0x40,0x80,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x0E,0x35,0x73,0x7B,0xBE,0xFE,0x3E,0xFC,0xF8,0xFC,0xFC,0xFE,0xDE,
      0xDD,0xFF,0xEF,0xBF,0xFF,0xFF,0xDE,0xBF,0x9C,0x9C,0x9C,0xFC,0x7E,0xFD,0xFE,0xFE,
      0xFE,0xFC,0xFC,0xFC,0xF8,0xF9,0xF2,0xE2,0xC0,0xC5,0x07,0x06,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,
      0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,
      0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,0xF0,
      0xF0,0xE0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x07,0x0E,0x17,0x17,0x17,0x1F,0xDE,0xBE,0x6F,0x2F,0x3B,0x1F,0x0E,
      0x0F,0x1E,0x14,0x0E,0x18,0x16,0x0D,0x09,0x86,0xCC,0xFB,0xFF,0xFF,0xFE,0xFF,0xFE,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xB7,0x0F,0x0C,0x00,0x00,0x80,0x80,
      0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0x7F,0x7F,0x3F,0x9F,0x5F,0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFD,0xF9,0xF5,0xE9,
      0x80,0x00,0x00,0x02,0x02,0x02,0x02,0x08,0x01,0x02,0x00,0x01,0x07,0x05,0x07,0x07,
      0x0F,0x9F,0x3F,0x7F,0xFF,0xFF,0xFF,0xFE,0xFE,0xF8,0xF0,0xE0,0x80,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x13,
      0x13,0x15,0x05,0x13,0x10,0x10,0x10,0x08,0x08,0x0D,0x07,0x00,0x00,0x80,0xC0,0xC0,
      0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,
      0xBF,0xDF,0x5F,0x97,0x87,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xFC,0xFE,0xFF,0xFF,0xFF,
      0xFF,0x7F,0xBF,0x9F,0xEF,0xEF,0xE7,0xF3,0xF9,0xFC,0xFF,0xFF,0xBF,0x87,0x83,0xB1,
      0xE4,0xCD,0xC4,0xE3,0xE1,0xF0,0xF8,0xFC,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,
      0x07,0x00,0x02,0x02,0x02,0x06,0x06,0x06,0x0E,0x0F,0x0F,0x8E,0x7E,0x3E,0x1E,0x87,
      0x87,0xC7,0xF3,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x79,0x38,0x00,0x00,
      0x00,0x00,0x00,0x40,0x60,0x40,0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xC0,0xE0,0xE0,0xFC,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0xFF,0xF3,0xFD,0xFD,0xFF,0xFD,0xFF,
      0xFF,0xFE,0xFE,0xFF,0xFF,0xFF,0x7F,0x7F,0xBF,0x7F,0x7F,0xFF,0xEF,0xE7,0xF3,0xFD,
      0xCE,0xE7,0xF6,0xF3,0xFB,0xF3,0xEF,0xEF,0xE7,0xE7,0xE7,0xC7,0xE7,0x67,0x67,0x67,
      0x67,0x67,0x67,0x47,0x03,0x03,0x03,0x03,0x01,0x03,0x00,0x00,0x00,0x80,0x80,0x80,
      0x80,0xC0,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFD,0xFC,0xFE,0xFF,0x7F,0x7F,
      0x7F,0x3F,0x3F,0x3F,0x1F,0x1F,0x0F,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x03,0x03,0x07,0x07,
      0x0F,0x0F,0x0F,0x1B,0x1B,0x1B,0x1B,0x1B,0x03,0x07,0x07,0x05,0x01,0x01,0x03,0x00,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x81,0x81,0x80,0x00,0x00,0xC0,0xC0,0xC0,0x80,0xA0,0x60,0xE0,0x60,0x60,
      0x6C,0x7C,0x36,0x36,0x36,0x3B,0x39,0x39,0x38,0x18,0x18,0x1C,0x1C,0x1C,0x1C,0x1C,
      0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x0E,0x0E,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x07,
      0x07,0x07,0x03,0x07,0x03,0x05,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0xC0,0xA0,0xE0,0xD0,0x70,0x68,0x78,
      0xBC,0xBC,0xBC,0xF6,0xDE,0xDE,0xEE,0x66,0x66,0x6E,0x7E,0x72,0x36,0x3A,0x38,0x39,
      0x18,0x19,0x05,0x0D,0x03,0x03,0x02,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x90,0x88,0x86,0x85,0x8A,0x8B,0x85,0x85,0x87,0x82,0x82,0x83,0x81,0x83,
      0x83,0x83,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
};

/****************************************************************************
函数功能:LCD延时程序
入口参数:t
出口参数:
****************************************************************************/
void LCDdelay(unsigned int t)
{
	unsigned int i,j;
	for(i=0;i<t;i++);
	for(j=0;j<10;j++);
}
/****************************************************************************
状态检查,LCD是否忙


*****************************************************************************/
void CheckState()		
{
   unsigned char dat,DATA;//状态信息(判断是否忙)
   LCDDi=0; // 数据\指令选择,D/I(RS)="L" ,表示 DB7∽DB0 为显示指令数据 
   LCDRW=1; //R/W="H" ,E="H"数据被读到DB7∽DB0 
   do
   {
      DATA=0x00;
      LCDEnable=1;	//EN下降源
	  LCDdelay(2);//延时
	  dat=DATA;
      LCDEnable=0;
      dat=0x80 & dat; //仅当第7位为0时才可操作(判别busy信号)
    }
    while(!(dat==0x00));
}
/*****************************************************************************
函数功能:写命令到LCD程序,RS(DI)=L,RW=L,EN=H,即来一个脉冲写一次
入口参数:cmdcode
出口参数:
*****************************************************************************/
void write_com(unsigned char cmdcode)
{
    CheckState();//检测LCD是否忙
	LCDDi=0;
	LCDRW=0;
	P1=cmdcode;		
	LCDdelay(2);
	LCDEnable=1;
	LCDdelay(2);
	LCDEnable=0;
}
/*****************************************************************************
函数功能:LCD初始化程序
入口参数:
出口参数:
*****************************************************************************/
void init_lcd()
{
	LCDdelay(100);	
	LCDMcs=1;//刚开始关闭两屏
	LCDScs=1;
	LCDdelay(100);
	write_com(LCDLCDDisp_Off);	 //写初始化命令
	write_com(Page_Add+0);
	write_com(Start_Line+0);
	write_com(LCDCol_Add+0);
	write_com(LCDLCDDisp_On);
}
/*****************************************************************************
函数功能:写数据到LCD程序,RS(DI)=H,RW=L,EN=H,即来一个脉冲写一次
入口参数:LCDDispdata
出口参数:
*****************************************************************************/
void write_data(unsigned char LCDDispdata)
{
    CheckState();//检测LCD是否忙
	LCDDi=1;
	LCDRW=0;
	P1=LCDDispdata;
	LCDdelay(2);
	LCDEnable=1;
	LCDdelay(2);
	LCDEnable=0;
}
/*****************************************************************************
函数功能:清除LCD内存程序
入口参数:pag,col,hzk
出口参数:
*****************************************************************************/
void Clr_Scr()
{
	unsigned char j,k;
	LCDMcs=0; //左、右屏均开显示
	LCDScs=0;
 	write_com(Page_Add+0);
 	write_com(LCDCol_Add+0);
 	for(k=0;k<8;k++)//控制页数0-7,共8页
 	{
		write_com(Page_Add+k); //每页每页进行写
  		for(j=0;j<64;j++)  //每页最多可写32个中文文字或64个ASCII字符
		{
      		write_com(LCDCol_Add+j);
			write_data(0x00);//控制列数0-63,共64列,写点内容,列地址自动加1
		}
	}
}
/*****************************************************************************
函数功能:左屏位置显示
入口参数:page,column,hzk
出口参数:
*****************************************************************************/
void Bmp_Left_Disp(unsigned char page,unsigned char column, unsigned char code *Bmp)
{
	unsigned char j=0,i=0;
	for(j=0;j<8;j++)
	{
		write_com(Page_Add+page+j);
		write_com(LCDCol_Add+column);
		for(i=0;i<64;i++) 
			write_data(Bmp[128*j+i]);
	}
}
/*****************************************************************************
函数功能:右屏位置显示
入口参数:page,column,hzk
出口参数:
*****************************************************************************/
void Bmp_Right_Disp(unsigned char page,unsigned char column, unsigned char code *Bmp)
{
	unsigned char j=0,i=0;
	for(j=0;j<8;j++)
	{
		write_com(Page_Add+page+j);
		write_com(LCDCol_Add+column);
		for(i=64;i<128;i++) 
			write_data(Bmp[128*j+i]);
	}
}

void main()
{
	init_lcd();
	Clr_Scr();
	
	LCDMcs=0; //左屏开显示
	LCDScs=1;
    Bmp_Left_Disp(0,0,Hz);
    LCDMcs=1; //右屏开显示
	LCDScs=0;
	Bmp_Right_Disp(0,0,Hz);

	while(1)
    {
  
	}
}

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿鹿学术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值