12864带字库图文显示
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/*******************************************************************************
描述: *
12864标准字库液晶演示 数据p0,控制p2
更多资料请点击:
QQ:1027733767
QQ讨论群:145504983
********************************************************************************/
#include
#include
#define uchar unsigned char
#define uint unsigned int
/************* 12864LCD引脚定义 *************/
#define LCD_data P0 //数据口
sbit LCD_RS = P1^0; //寄存器选择输入
sbit LCD_RW = P1^1; //液晶读/写控制
sbit LCD_EN = P1^2; //液晶使能控制
sbit LCD_PSB = P1^6; //串/并方式控制
sbit LCD_RST = P1^7; //液晶复位端口
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
/*********************************************************/
uchar code DIS1[] = {" 星梦电子 "};
uchar code DIS2[] = {"自学单片机第一站"};
uchar code DIS3[] = {" 祝你学习进步 "};
uchar code DIS4[] = {" QQ:1027733767 "};
/*********************************************************/
uchar code Photo1[] ={
/*-- 调入了一幅图像:C:\Documents and Settings\Administrator\桌面\223.bmp --*/
/*-- 宽度x高度=128x64 --*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xE6,0xFE,0x00,0x07,0x80,0x70,0x3D,0xFF,0xB4,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xE6,0xFE,0x00,0x07,0x80,0x70,0x3D,0xFF,0xB4,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xE5,0xFF,0xF6,0xFF,0xBE,0x7F,0x20,0x10,0x77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F,0x3F,0xFC,0xFE,0xFF,0xFF,
0xFC,0xFE,0x7F,0x0F,0xF8,0x00,0x01,0x83,0x3F,0x87,0xFF,0x3F,0xFC,0xFE,0xFF,0xFF,
0xFF,0xFF,0xBE,0x03,0xF0,0x00,0x00,0x02,0x2F,0xE0,0x7F,0x87,0xFD,0xFF,0xFB,0xFF,
0xFC,0xFD,0xBC,0xE1,0xE0,0x00,0x03,0xCC,0x20,0xF8,0x07,0xC1,0xFF,0xFF,0xEF,0xFF,
0xFF,0xFE,0x1D,0x11,0xE0,0x00,0x00,0x20,0x20,0x0F,0x00,0x60,0x7F,0x0F,0xE4,0xFF,
0xFF,0xFE,0x1D,0x11,0xE0,0x00,0x00,0x20,0x20,0x0F,0x00,0x60,0x7F,0x0F,0xE4,0xFF,
0xFF,0xFA,0x1C,0x2D,0x80,0x00,0x00,0x00,0xE0,0x00,0x00,0x18,0x3E,0x07,0xE3,0xFF,
0xFF,0xFC,0x04,0x2C,0x00,0x00,0x00,0x00,0xE0,0x1E,0x00,0x00,0x1C,0x31,0x87,0x7F,
0xFF,0xF4,0x02,0x10,0x00,0x00,0x00,0x01,0x20,0x60,0x00,0x00,0x1C,0xC9,0x84,0xFF,
0xFF,0xF4,0x02,0x10,0x00,0x00,0x00,0x01,0x20,0x60,0x00,0x00,0x1C,0xC9,0x84,0xFF,
0xFF,0xF8,0x03,0x00,0x00,0x03,0xFC,0x01,0x10,0x00,0x00,0x00,0x0D,0x21,0x00,0xBF,
0xFF,0xC8,0x03,0xC0,0x00,0x0F,0xFE,0x02,0x10,0x00,0x00,0x00,0x01,0x21,0x00,0x7F,
0xFF,0xF0,0x07,0xE0,0x00,0x00,0x1F,0x8C,0x0C,0x01,0xFC,0x00,0x00,0xC6,0x00,0x3F,
0xFF,0xF0,0x07,0xE0,0x00,0x00,0x1F,0x8C,0x0C,0x01,0xFC,0x00,0x00,0xC6,0x00,0x3F,
0xFF,0xB0,0x1F,0x20,0x00,0x00,0x3C,0x10,0x0C,0x67,0xFF,0x80,0x00,0x0F,0x80,0x7F,
0xFF,0xC0,0x00,0x20,0x00,0x00,0x38,0x20,0x02,0x1F,0x80,0x00,0x00,0x1F,0xE0,0x4F,
0xFF,0x40,0x00,0xC0,0x00,0x00,0x18,0x40,0x01,0x01,0x80,0x00,0x00,0x10,0x10,0x3F,
0xFF,0x40,0x00,0xC0,0x00,0x00,0x18,0x40,0x01,0x01,0x80,0x00,0x00,0x10,0x10,0x3F,
0xFF,0x80,0x1F,0x00,0x00,0x84,0x60,0x40,0x00,0x81,0xC0,0x00,0x00,0x10,0x00,0x3B,
0xFF,0xC0,0x61,0x00,0x00,0x43,0x01,0x80,0x00,0x60,0xC0,0x00,0x00,0x10,0x00,0x31,
0xFF,0x41,0xA0,0xC0,0x00,0xB0,0x81,0x80,0x00,0x10,0x80,0x00,0x00,0x18,0x00,0x3B,
0xFF,0x41,0xA0,0xC0,0x00,0xB0,0x81,0x80,0x00,0x10,0x80,0x00,0x00,0x18,0x00,0x3B,
0xFC,0x02,0x18,0xC0,0x00,0x40,0x01,0x80,0x00,0x10,0x73,0x18,0x00,0x16,0x00,0x3F,
0xFF,0x02,0x04,0x20,0xF0,0x00,0x01,0x80,0x00,0x08,0x04,0x20,0x0F,0xE0,0x00,0x0B,
0xFF,0x84,0x04,0x10,0x8E,0x00,0x02,0x00,0x00,0x08,0x08,0x58,0x12,0x30,0x80,0x0F,
0xFF,0x84,0x04,0x10,0x8E,0x00,0x02,0x00,0x00,0x08,0x08,0x58,0x12,0x30,0x80,0x0F,
0xFB,0x04,0x02,0x0F,0x09,0xC0,0x1C,0x00,0x00,0x08,0x00,0x20,0x21,0x08,0x60,0x0B,
0xFF,0x04,0x02,0x00,0x08,0x7F,0xE0,0x00,0x00,0x08,0x00,0x00,0x60,0xC0,0x10,0x07,
0xFB,0x84,0x02,0x00,0x08,0x40,0x00,0x00,0x00,0x06,0x00,0x03,0xA0,0xC0,0x00,0x0D,
0xFB,0x84,0x02,0x00,0x08,0x40,0x00,0x00,0x00,0x06,0x00,0x03,0xA0,0xC0,0x00,0x0D,
0xFF,0x04,0x02,0x00,0x08,0x40,0x00,0x00,0x00,0x01,0x80,0x3C,0x40,0x20,0x08,0x06,
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,
};
/******************************************************************************/
uchar code Photo2[] ={
/*-- 调入了一幅图像:C:\Documents and Settings\Administrator\桌面\328.bmp --*/
/*-- 宽度x高度=128x64 --*/
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
0x8A,0x52,0xB4,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x4B,0x29,0x40,0x00,0x00,0x00,
0xB4,0x00,0x02,0x10,0x4A,0x20,0x00,0x00,0x00,0x01,0x37,0xFE,0xC0,0x00,0x00,0x00,
0xB4,0x00,0x02,0x10,0x4A,0x20,0x00,0x00,0x00,0x01,0x37,0xFE,0xC0,0x00,0x00,0x00,
0x42,0x52,0xB0,0x46,0x80,0x00,0x00,0x00,0x00,0x28,0xCF,0xF9,0x00,0x00,0x00,0x00,
0xB9,0xA0,0x04,0x00,0x00,0x06,0x30,0x00,0x00,0x01,0x7A,0xF0,0x00,0x00,0x00,0x00,
0x46,0x52,0xB1,0xA8,0x4A,0x20,0x00,0x00,0x04,0xD7,0xB5,0x00,0x00,0x00,0x00,0x00,
0x46,0x52,0xB1,0xA8,0x4A,0x20,0x00,0x00,0x04,0xD7,0xB5,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFD,0x04,0x01,0x00,0x00,0x00,0x00,0x02,0x29,0x4A,0xC0,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xF2,0x50,0x00,0x40,0x00,0x00,0x00,0xD6,0xB4,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xBD,0x86,0xB4,0x00,0x80,0x00,0x01,0x16,0x40,0x08,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xBD,0x86,0xB4,0x00,0x80,0x00,0x01,0x16,0x40,0x08,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFB,0xB0,0x00,0x10,0x00,0x00,0x0A,0x28,0x89,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xEF,0xB0,0x40,0x00,0x00,0x00,0xC6,0x00,0x11,0x30,0xC0,0x00,0x00,
0xB5,0xFF,0xFF,0xF9,0x4A,0x00,0x00,0x00,0x01,0x10,0x02,0x26,0x4B,0xE9,0x00,0x00,
0xB5,0xFF,0xFF,0xF9,0x4A,0x00,0x00,0x00,0x01,0x10,0x02,0x26,0x4B,0xE9,0x00,0x00,
0x82,0x2F,0xFF,0xFF,0xC9,0x88,0x00,0x00,0x00,0x00,0x30,0x01,0x7F,0xFF,0xA0,0x00,
0x34,0x41,0x7F,0xFF,0xF4,0x20,0x00,0x00,0x00,0x00,0x02,0xDF,0xFF,0xFF,0xE0,0x00,
0x42,0x2C,0x05,0xBF,0xFB,0x80,0x00,0x00,0x00,0x00,0x08,0x2F,0xFF,0xFF,0xFE,0x00,
0x88,0x41,0x4A,0x57,0xCC,0x50,0x00,0x00,0x00,0x00,0x81,0xFF,0xFF,0xFF,0xFF,0x00,
0x88,0x41,0x4A,0x57,0xCC,0x50,0x00,0x00,0x00,0x00,0x81,0xFF,0xFF,0xFF,0xFF,0x00,
0x42,0x2C,0x00,0x08,0x77,0x86,0x00,0x00,0x00,0x00,0x46,0xFF,0xFF,0xFF,0xFE,0x20,
0x08,0x41,0x4A,0x51,0xBA,0x68,0x00,0x00,0x00,0x00,0x0B,0xFE,0xFF,0xFF,0x7F,0xC0,
0xC2,0x2C,0x00,0x08,0x05,0x80,0x00,0x00,0x00,0x00,0x83,0xF8,0x7F,0xE7,0x1F,0xE0,
0xC2,0x2C,0x00,0x08,0x05,0x80,0x00,0x00,0x00,0x00,0x83,0xF8,0x7F,0xE7,0x1F,0xE0,
0x0A,0x52,0xB5,0xA1,0x4A,0x69,0x00,0x00,0x00,0x0
1,0x3F,0xF0,0xFF,0xC8,0x3C,0xF0,
0xC5,0xAD,0x79,0x88,0x01,0x90,0x00,0x00,0x00,0x00,0x07,0xE0,0x7F,0x21,0x5A,0x00,
0x32,0x7F,0xFF,0xF6,0x4A,0x29,0x00,0x00,0x00,0x00,0x4F,0x08,0xFF,0xEF,0xE0,0x20,
0x32,0x7F,0xFF,0xF6,0x4A,0x29,0x00,0x00,0x00,0x00,0x4F,0x08,0xFF,0xEF,0xE0,0x20,
0x8A,0x7F,0xFF,0xFF,0x00,0x50,0x00,0x00,0x00,0x00,0x0F,0x20,0x7F,0xFF,0x9E,0x00,
0x47,0xFF,0xFF,0xFF,0xF2,0x29,0x00,0x00,0x00,0x01,0x3F,0x06,0x3F,0xFE,0xA0,0x00,
0xB9,0xFF,0xFF,0xFF,0xFC,0x56,0x40,0x00,0x00,0x00,0x3E,0xD0,0x0F,0xF9,0x00,0x00,
0xB9,0xFF,0xFF,0xFF,0xFC,0x56,0x40,0x00,0x00,0x00,0x3E,0xD0,0x0F,0xF9,0x00,0x00,
0x4F,0xFF,0xC7,0xFF,0xFD,0xA9,0x00,0x00,0x00,0x00,0xBF,0x29,0xFF,0xE0,0x00,0x00,
0xB7,0xFF,0xB7,0xFF,0xFF,0x96,0x40,0x00,0x00,0x00,0x3F,0xFF,0xBD,0x00,0x00,0x00,
0x7F,0xFF,0x47,0xF9,0x7F,0xC9,0x00,0x00,0x00,0x00,0x7F,0x29,0x40,0x00,0x00,0x00,
0x7F,0xFF,0x47,0xF9,0x7F,0xC9,0x00,0x00,0x00,0x00,0x7F,0x29,0x40,0x00,0x00,0x00,
0xB7,0xFE,0x37,0xFF,0x7D,0xF6,0xB0,0x00,0x00,0x00,0x3A,0xD0,0x30,0x00,0x00,0x00,
0xCF,0xFE,0x43,0xFF,0xF9,0xC1,0x00,0x00,0x00,0x00,0xB0,0x06,0x00,0x00,0x00,0x00,
0x37,0xFF,0x4B,0xFF,0xFF,0xF6,0x48,0x00,0x00,0x00,0x05,0x20,0x80,0x00,0x00,0x00,
0x37,0xFF,0x4B,0xFF,0xFF,0xF6,0x48,0x00,0x00,0x00,0x05,0x20,0x80,0x00,0x00,0x00,
0x8B,0xFF,0xC3,0xFF,0xFF,0xE1,0x80,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,
0x74,0x3F,0xFD,0xFF,0x4A,0x78,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xD3,0xFF,0xF9,0x30,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xD3,0xFF,0xF9,0x30,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC8,0x2D,0x4F,0xA6,0x81,0xA9,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x05,0x90,0xB0,0x48,0x0A,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xB0,0x4D,0x0A,0x00,0x00,0x46,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x10,0x40,0x21,0x44,0x11,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x10,0x40,0x21,0x44,0x11,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x41,0x35,0x88,0x00,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x12,0x00,0x21,0x34,0x11,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xB5,0x80,0xB5,0x80,0x82,0x48,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xB5,0x80,0xB5,0x80,0x82,0x48,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x22,0x00,0x16,0x08,0x11,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xCA,0x00,0xB4,0x40,0x40,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x4C,0x00,0x00,0x04,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x4C,0x00,0x00,0x04,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x20,0x89,0x91,0x31,0x96,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x44,0x02,0x00,0x00,0x00,0x20,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,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,
};
/*******************************************************************/
/* */
/* 延时函数 */
/* */
/*******************************************************************/
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<150;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/*******************************************************************/
/* */
/* 延时函数 */
/* */
/*******************************************************************/
void delay1(int ms)
{
while(ms--)
{
uchar y;
for(y=0;y<100;y++) ;
}
}
/*******************************************************************/
/* */
/*检查LCD忙状态 */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。 */
/* */
/*******************************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
/*******************************************************************/
/* */
/*写指令数据到LCD */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */
/* */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/*写显示数据到LCD */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。 */
/* */
/*******************************************************************/
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/* LCD初始化设定 */
/* */
/*******************************************************************/
void lcd_init()
{
LCD_PSB = 1; //并口方式
LCD_RST = 0; //液晶复位
delay(3);
LCD_RST = 1;
delay(3);
lcd_wcmd(0x34); //扩充指令操作
delay(5);
lcd_wcmd(0x30); //基本指令操作
delay(5);
lcd_wcmd(0x0C); //显示开,关光标
delay(5);
lcd_wcmd(0x01); //清除LCD的显示内容
delay(5);
}
/*********************************************************/
/* */
/* 设定显示位置 */
/* */
/*********************************************************/
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==1)
{X=0x80;}
else if (X==2)
{X=0x90;}
else if (X==3)
{X=0x88;}
else if (X==4)
{X=0x98;}
pos = X+Y ;
lcd_wcmd(pos); //显示地址
}
/*********************************************************
* *
* 闪烁函数 *
* *
*********************************************************/
void lcdflag()
{
lcd_wcmd(0x08);
delay(400);
lcd_wcmd(0x0c);
delay(400);
lcd_wcmd(0x08);
delay(400);
lcd_wcmd(0x0c);
delay(400);
lcd_wcmd(0x08);
delay(200);
lcd_wcmd(0x0c);
delay(5);
lcd_wcmd(0x01);
delay(5);
}
/*********************************************************
* *
* 图形显示 *
* *
*********************************************************/
void photodisplay(uchar *bmp)
{
uchar i,j;
lcd_wcmd(0x34); //写数据时,关闭图形显示
for(i=0;i<32;i++)
{
lcd_wcmd(0x80+i); //先写入水平坐标值
lcd_wcmd(0x80); //写入垂直坐标值
for(j=0;j<16;j++) //再写入两个8位元的数据
lcd_wdat(*bmp++);
delay1(1);
}
for(i=0;i<32;i++)
{
lcd_wcmd(0x80+i);
lcd_wcmd(0x88);
for(j=0;j<16;j++)
lcd_wdat(*bmp++);
delay1(1);
}
lcd_wcmd(0x36); //写完数据,开图形显示
}
/*******************
**************************************
* *
* 清屏函数 *
* *
*********************************************************/
void clr_screen()
{
lcd_wcmd(0x34); //扩充指令操作
delay(5);
lcd_wcmd(0x30); //基本指令操作
delay(5);
lcd_wcmd(0x01); //清屏
delay(5);
}
/**********************************************************
; 显示字符表代码
**********************************************************/
void bytecode()
{
uchar s;
clr_screen(); //清屏
lcd_wcmd(0x80); //设置显示位置为第一行
for(s=0;s<16;s++)
{
lcd_wdat(0x30+s);
}
lcd_wcmd(0x90); //设置显示位置为第二行
for(s=0;s<16;s++)
{
lcd_wdat(0x40+s);
}
lcd_wcmd(0x88); //设置显示位置为第三行
for(s=0;s<16;s++)
{
lcd_wdat(0x50+s);
}
lcd_wcmd(0x98); //设置显示位置为第四行
for(s=0;s<16;s++)
{
lcd_wdat(0x60+s);
}
}
/*********************************************************
* *
* 主函数 *
* *
*********************************************************/
void main()
{
uchar i;
delay(100); //上电,等待稳定
lcd_init(); //初始化LCD
while(1)
{
lcd_pos(1,0); //设置显示位置为第一行
for(i=0;i<16;i++)
{
lcd_wdat(DIS1[i]);
delay(30);
}
lcd_pos(2,0); //设置显示位置为第二行
for(i=0;i<16;i++)
{
lcd_wdat(DIS2[i]);
delay(30);
}
lcd_pos(3,0); //设置显示位置为第三行
for(i=0;i<16;i++)
{
lcd_wdat(DIS3[i]);
delay(30);
}
lcd_pos(4,0); //设置显示位置为第四行
for(i=0;i<16;i++)
{
lcd_wdat(DIS4[i]);
delay(30);
}
delay(1000);
lcdflag();
clr_screen(); //清屏
photodisplay(Photo1); //显示图片1
delay(2000);
clr_screen(); //清屏
photodisplay(Photo2); //显示图片2
delay(2000);
bytecode(); //显示字符表代码
delay(2000);
clr_screen();
}
}
/*********************************************************/