一、功能描述
显示海绵宝宝图标
二、程序
#include <REGX51.H>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit RET=P2^0;
sbit E=P2^1;
sbit wr=P2^2;
sbit rs=P2^3;
sbit CS2=P2^4;
sbit CS1=P2^5;
uchar code tupian_ZM[]={
/*-- ???????:C:\Users\Administrator\Desktop\????.bmp --*/
/*-- ??x??=128x64 --*/
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,0xC0,0x00,0x20,0x00,0x00,0x10,
0x88,0x48,0x08,0x08,0x08,0x04,0x84,0x02,0x01,0x8F,0x01,0x01,0x01,0x01,0x10,0x02,
0x00,0x00,0x00,0x80,0x50,0x00,0x00,0x00,0x00,0x84,0x04,0x00,0x08,0x08,0x08,0x08,
0x08,0x88,0x08,0x08,0x10,0x10,0x00,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,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,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,0x39,0x46,0x00,0x00,0x00,0x03,
0x02,0x20,0x00,0x00,0x00,0x01,0x40,0x10,0x0F,0x00,0x00,0x00,0x08,0x00,0x00,0x88,
0x84,0x80,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x80,0x80,0x80,
0x81,0x01,0x00,0x00,0x00,0x04,0x06,0x00,0x00,0x00,0x00,0x00,0x18,0x10,0x00,0x00,
0x00,0x00,0x10,0x18,0x00,0x00,0x00,0x60,0xA0,0x00,0x01,0x01,0x42,0x22,0x04,0xA4,
0x04,0x04,0xC4,0x64,0x10,0x08,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,0xE0,0x1F,0x00,0x00,0x98,0x00,0x00,
0x80,0x00,0x08,0x04,0x10,0x00,0x83,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x81,0x30,
0x0A,0x18,0x10,0x20,0x40,0x44,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
0x00,0x00,0x00,0x08,0x08,0x04,0x02,0x01,0x06,0x00,0x04,0x0E,0x06,0x06,0x08,0x00,
0x00,0x00,0x20,0xC0,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x08,0x08,
0x04,0x02,0x03,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,0xC0,0x20,0x20,0x80,0x10,0x88,0x0A,0x01,0x00,0x00,0x80,0x39,0x00,0x00,
0x80,0x40,0x0C,0x02,0x01,0x20,0x08,0x01,0x00,0x00,0x40,0x10,0x00,0x00,0x07,0x10,
0x40,0x10,0x90,0x00,0x00,0x00,0x20,0x40,0x09,0x17,0x12,0x02,0x00,0x80,0x10,0x0C,
0x24,0x08,0x00,0x49,0x09,0x49,0x29,0x18,0x08,0x00,0x00,0x02,0x04,0x48,0x08,0x00,
0x80,0x00,0x01,0x00,0x00,0x80,0x40,0x40,0x10,0x04,0x02,0x03,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,0x40,0x20,0x90,0x40,
0x28,0x14,0x02,0x69,0x4C,0x06,0x82,0x89,0x92,0x12,0x10,0x01,0x00,0xC0,0x21,0x08,
0x02,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x04,0x04,0x04,0x80,0x88,0x88,0x18,0x08,
0x01,0x22,0x0A,0x10,0x55,0x14,0x80,0x62,0x22,0x2A,0x68,0x00,0x08,0x00,0x03,0x40,
0x40,0x42,0x01,0x00,0x00,0x00,0x18,0x04,0x02,0x02,0x00,0x12,0x0C,0x40,0x20,0x30,
0x30,0x28,0x24,0x23,0x00,0x00,0x00,0x00,0x00,0x16,0x0C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x20,0x20,0x40,0x04,0x85,0x02,0x00,0x00,0x07,0x08,0x80,0x10,0x40,0xA0,0x00,0xC0,
0x08,0x10,0x01,0x00,0x00,0x22,0x40,0x48,0x40,0x20,0x10,0x08,0x08,0x08,0x10,0x06,
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x21,0x95,0x4B,0x29,0x10,0x10,
0x12,0x02,0x02,0x00,0x00,0x14,0x0C,0x04,0x04,0x00,0x08,0x08,0x08,0x09,0x09,0x01,
0x13,0x34,0x90,0x90,0x80,0x00,0x23,0x23,0x22,0x26,0x04,0xC4,0x40,0x40,0x48,0x48,
0x48,0x08,0x08,0x08,0x80,0x40,0x20,0x10,0x0C,0x06,0x03,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,0x01,0x00,0x02,0x00,0x03,0x02,0x02,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,
0x40,0x20,0x10,0x08,0x44,0x66,0xD3,0x89,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0x20,0x10,
0xCC,0x62,0x11,0x0C,0x02,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,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x00,0x42,0x02,0x02,0x23,0x20,0x00,
0x10,0x08,0x00,0x04,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x25,0x70,0x00,0x00,0x01,0x20,0x00,0x0A,
0x00,0x10,0x60,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,
};
void delayms(uint x)
{
uchar i;
while(x--)
for(i=0;i<123;i++);
}
void writeData(uchar x)
{
rs=1;
wr=0;
P0=x;
_nop_();
E=1;
_nop_();
E=0;
}
void writeCon(uchar x)
{
rs=0;
wr=0;
P0=x;
_nop_();
E=1;
_nop_();
E=0;
}
void clear()
{
uint i,j;
CS1=CS2=1;
for(i=0;i<8;i++)
{
writeCon(0xb8+i);
writeCon(0x40);
for(j=0;j<64;j++)
{
writeData(0x00);
}
}
}
void init12864()
{
RET=0;
delayms(15);
RET=1;
writeCon(0x3e);
writeCon(0xb8);
writeCon(0x40);
writeCon(0xc0);
writeCon(0x3f);
}
void writeTP(uchar code*img)
{
uchar i,j;
for(j=0;j<8;j++)
{
CS1=0;CS2=1;
writeCon(0xb8+j);
for(i=0;i<64;i++)
writeData(img[j*128+i]);
CS1=1;CS2=0;
writeCon(0xb8+j);
for(i=64;i<128;i++)
writeData(img[j*128+i]);
}
}
void main()
{
init12864();
clear();
writeTP(tupian_ZM);
while(1);
}
三、电路图
四、小结
这个程序一开始我本来以为文字成功的程序显示图片没有问题,单是事情出乎了我的意料。它并没有显示出图片,一开始连点都没有,后来经过同学们的帮助让我显示了几个黑点。然后经过仔细检查让我找出了问题所在,我把一个重要的一行给忘了打了,所以谢谢老师跟同学的指导和帮我细心排查错误。让我非常感谢。
网友评论