程序100%可以运行
拿走用不谢
#include<reg51.h>
#include<intrins.h>
#include<stdlib.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD_DB P0
uchar num,m;
sbit RS=P2^2;
sbit RW=P2^1;
sbit EN=P2^0;
sbit CS1=P2^4;
sbit CS2=P2^3;
unsigned char code bai[]=
{0x00,0x00,0xE0,0x20,0x30,0x28,0x26,0x22,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0x09,0x09,0x09,0x09,0x09,0x08,0x30,0x0F,0x00,0x00,0x00,0x00};
unsigned char code ri[]=
{0x00,0x00,0x00,0x00,0xF8,0x88,0x88,0x44,0x44,0x04,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0x08,0x04,0x04,0x04,0x08,0x0F,0x00,0x00,0x00,0x00,0x00};
unsigned char code yi[]=
{0x80,0x40,0xF0,0x0E,0x00,0x10,0x90,0x50,0xB2,0x14,0x88,0x48,0x08,0x00,0x00,0x00,
0x00,0x00,0x3F,0x04,0x02,0x01,0x3F,0x10,0x08,0x01,0x02,0x04,0x0C,0x08,0x08,0x00};
unsigned char code shan[]=
{0x00,0x00,0x80,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1F,0x10,0x08,0x08,0x08,0x07,0x04,0x04,0x04,0x04,0x1F,0x00,0x00,0x00};
unsigned char code jin[]=
{0x00,0x00,0x00,0xC0,0x3C,0x12,0x32,0x52,0x92,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x04,0x03,0x00,0x00,0x11,0x22,0x64,0x00,0x01,0x01,0x03,0x02,0x02,0x02,0x00};
unsigned char code dou[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x2C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char code huang[]=
{0x40,0x40,0x40,0x40,0x48,0xBE,0xA8,0xE8,0xB8,0xA7,0xA4,0x24,0x20,0x20,0x20,0x00,
0x00,0x00,0x40,0x40,0x2F,0x18,0x0A,0x0F,0x0A,0x14,0x27,0x60,0x00,0x00,0x00,0x00};
unsigned char code he[]=
{0x00,0x10,0x20,0x02,0x04,0xC8,0x48,0x28,0xE8,0x08,0x08,0xFC,0x04,0x04,0x04,0x00,
0x00,0x00,0x1C,0x03,0x00,0x00,0x01,0x01,0x01,0x00,0x10,0x3F,0x00,0x00,0x00,0x00};
unsigned char code ru[]=
{0x00,0x00,0x00,0x00,0x08,0xC8,0x30,0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x18,0x10,0x10,0x00};
unsigned char code hai[]=
{0x00,0x20,0x44,0x08,0x00,0x10,0xE8,0x2F,0xE8,0xA4,0x94,0xF4,0x80,0x80,0x80,0x00,
0x00,0x18,0x06,0x01,0x01,0x0D,0x0B,0x09,0x2B,0x48,0x38,0x0F,0x08,0x08,0x00,0x00};
unsigned char code liu[]=
{0x00,0x20,0x44,0x08,0x00,0x10,0xD0,0xB0,0x51,0x4A,0x68,0x48,0x08,0x00,0x00,0x00,
0x00,0x00,0x18,0x07,0x20,0x18,0x06,0x00,0x1F,0x00,0x0F,0x10,0x10,0x10,0x1C,0x00};
unsigned char code ju[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char code yu[]=
{0x00,0x20,0x10,0xCC,0x30,0x40,0x84,0x48,0x20,0x98,0x16,0x50,0x30,0x00,0x00,0x00,
0x04,0x02,0x1D,0x12,0x12,0x0E,0x10,0x08,0x04,0x03,0x02,0x04,0x08,0x10,0x10,0x00};
unsigned char code qiong[]=
{0x00,0x30,0x18,0x48,0x28,0x18,0xC9,0x0A,0x14,0x34,0x24,0x04,0x1C,0x00,0x00,0x00,
0x00,0x20,0x20,0x12,0x0A,0x06,0x03,0x11,0x21,0x19,0x07,0x00,0x00,0x00,0x00,0x00};
unsigned char code qian[]=
{0x00,0x40,0x40,0x40,0x48,0x48,0x44,0xFC,0x22,0x23,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char code li[]=
{0x00,0x00,0x00,0x7C,0x84,0xA4,0xFC,0x54,0x52,0x42,0x72,0x0E,0x00,0x00,0x00,0x00,
0x00,0x20,0x20,0x20,0x24,0x24,0x1F,0x12,0x12,0x12,0x10,0x10,0x10,0x10,0x00,0x00};
unsigned char code mu[]=
{0x00,0x00,0x00,0x00,0xFC,0xA4,0xA4,0xA4,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0x04,0x04,0x04,0x04,0x08,0x1F,0x00,0x00,0x00,0x00,0x00};
unsigned char code geng[]=
{0x00,0x00,0x00,0x00,0xF0,0x12,0x52,0xFE,0xA9,0xA9,0xC9,0x38,0x00,0x00,0x00,0x00,
0x00,0x20,0x20,0x22,0x12,0x0D,0x05,0x0B,0x10,0x10,0x20,0x20,0x20,0x20,0x20,0x00};
unsigned char code shang[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x40,0x40,0x20,0x20,0x00,0x00,0x00,0x00,
0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00};
unsigned char code yi1[]=
{0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40,0x40,0xC0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char code ceng[]=
{0x00,0x00,0x00,0x00,0xFC,0x14,0x94,0x92,0x52,0x4A,0x4A,0x46,0x00,0x00,0x00,0x00,
0x10,0x08,0x04,0x03,0x22,0x32,0x1A,0x16,0x11,0x11,0x15,0x19,0x31,0x01,0x01,0x00};
unsigned char code lou[]=
{0x00,0x40,0x40,0xFE,0xA0,0x00,0xA0,0x68,0x10,0xFE,0x30,0x54,0x90,0x80,0x00,0x00,
0x04,0x02,0x01,0x3F,0x00,0x05,0x24,0x2C,0x1B,0x0A,0x16,0x12,0x22,0x02,0x02,0x00};
unsigned char code juhao[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void Read_busy()
{
P0=0;
RS=0;
RW=0;
EN=1;
while(P0&0x80);
EN=0;
}
void write_LCD_command(uchar cmd)
{
Read_busy();
RS=0;
RW=0;
LCD_DB=cmd;
EN=1;
_nop_();
_nop_();
EN=0;
}
void write_LCD_data(uchar dat)
{
Read_busy();
RS=1;
RW=0;
LCD_DB=dat;
EN=1;
_nop_();
_nop_();
EN=0;
}
void Set_page(uchar page)
{
page=0xb8|page;
write_LCD_command(page);
}
void Set_line(uchar startline)
{
startline=0xc0|startline;
write_LCD_command(startline);
}
void Set_column(uchar column)
{
column=column&0x3f;
column=0x40|column;
write_LCD_command(column);
}
void Setonoff(uchar onoff)
{
onoff=0x3e|onoff;
write_LCD_command(onoff);
}
void SelectScreen(uchar screen)
{
switch(screen)
{
case 0: CS1=0;CS2=0;break;
case 1: CS1=0;CS2=1;break;
case 2: CS1=1;CS2=0;break;
default:break;
}
}
void ClearScreen(uchar screen)
{
uchar i,j;
SelectScreen(screen);
for(i=0;i<8;i++)
{
Set_page(i);
Set_column(0);
for(j=0;j<64;j++)
{
write_LCD_data(0x00);//??0,??????1
}
}
}
void InitLCD()
{
Read_busy();
SelectScreen(0);
Setonoff(0);
SelectScreen(0);
Setonoff(1);
SelectScreen(0);
ClearScreen(0);
Set_line(0);
}
void Display(uchar ss,uchar page,uchar column,uchar *p)
{
uchar i;
SelectScreen(ss);
Set_page(page); //????
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i]);//??????
}
Set_page(page+1);//????
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i+16]);//??????
}
}
void main()
{
InitLCD();
ClearScreen(0);
while(1)
{
Set_line(m);//?????
Display(1,0,1*16,bai);
Display(1,0,2*16,ri);
Display(1,0,3*16,yi);
Set_line(m);//?????
Display(2,0,4*16,shan);
Display(2,0,5*16,jin);
Display(2,0,6*16,dou);
Display(1,2,1*16,huang);
Display(1,2,2*16,he);
Display(1,2,3*16,ru);
Display(2,2,4*16,hai);
Display(2,2,5*16,liu);
Display(2,2,6*16,ju);
Display(1,4,1*16,yu);
Display(1,4,2*16,qiong);
Display(1,4,3*16,qian);
Display(2,4,4*16,li);
Display(2,4,5*16,mu);
Display(2,4,6*16,dou);
Display(1,6,1*16,geng);
Display(1,6,2*16,shang);
Display(1,6,3*16,yi1);
Display(2,6,4*16,ceng);
Display(2,6,5*16,lou);
Display(2,6,6*16,ju);
m++;
if(m==63)
m=0;
}
}
|