#include"reg51.h"
#define uchar unsigned char
#define uint unsigned int
sbit lcdrst=P3^0;
sbit cs2=P3^5;
sbit cs1=P3^4;
sbit e=P3^2;
sbit rw=P3^3;
sbit rs=P3^1;
uchar code liu[]={0x00,0x08,0x28,0x49,0x8A,0x0C,0xC8,0x38,0x08,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
0x40,0x20,0x10,0x08,0x04,0x03,0x06,0x38,0x10,0x00,0x07,0x20,0x40,0x3F,0x00,0x00};
uchar code xiao[]={0x08,0x88,0x68,0xFF,0x28,0x48,0x00,0x88,0x68,0x09,0x0E,0x08,0xA8,0x48,0x88,0x00,
0x02,0x01,0x00,0xFF,0x00,0x40,0x42,0x21,0x26,0x18,0x18,0x26,0x61,0xC0,0x40,0x00};
uchar code jun[]={0x00,0x18,0x26,0x22,0xA2,0x72,0x2E,0xAA,0x22,0x22,0x22,0x32,0x22,0x0A,0x06,0x00,
0x00,0x10,0x10,0x12,0x13,0x12,0x12,0xFF,0x12,0x12,0x12,0x13,0x12,0x18,0x10,0x00};
uchar code dian[]={0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00};
uchar code zi[]={0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00};
uchar code xin[]={0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00,
0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00};
uchar code xi[]={0x00,0x00,0x00,0xFC,0x54,0x54,0x56,0x55,0x54,0x54,0x54,0xFC,0x00,0x00,0x00,0x00,
0x00,0x20,0x38,0x01,0x3D,0x41,0x41,0x45,0x59,0x41,0x41,0x71,0x00,0x08,0x30,0x00};
uchar code gong[]={0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00};
uchar code cheng[]={0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,
0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00};
uchar code zhuan[]={0x20,0x20,0x24,0x24,0xA4,0x64,0x3C,0x27,0x24,0x24,0xA4,0x24,0x24,0x20,0x20,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x09,0x11,0x29,0x45,0x03,0x01,0x00,0x00,0x00,0x00};
uchar code ye[]={0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00};
uchar code wu[]={0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00};
uchar code er[]={0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00};
uchar code ling[]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};
uchar code kongge[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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 kong[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
/*uchar code xing[]={0x20,0x24,0x2C,0x35,0xE6,0x34,0x2C,0x24,0x00,0xFC,0x24,0x24,0xE2,0x22,0x22,0x00,
0x21,0x11,0x4D,0x81,0x7F,0x05,0x59,0x21,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00};
uchar code de[]={0x00,0xF8,0x8C,0x8B,0x88,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,
0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x03,0x26,0x40,0x20,0x1F,0x00,0x00};
uchar code yi[]={0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar code nian[]={0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00,
0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00}; */
uchar code zhu[]={0x08,0x08,0x89,0xCE,0xA8,0x18,0x00,0xFE,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,
0x02,0x01,0x00,0xFF,0x00,0x83,0x40,0x30,0x0F,0x00,0x00,0x7F,0x80,0x80,0xF0,0x00};
uchar code yuan[]={0x00,0x00,0xFF,0x01,0x01,0x7D,0x55,0x57,0x55,0xD5,0x55,0x55,0x7D,0x01,0x01,0x00,
0x20,0x18,0x07,0x20,0x3A,0x02,0x39,0x40,0x4A,0x57,0x40,0x60,0x01,0x0A,0x30,0x00};
uchar code da[]={0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00};
uchar code jia[]={0x00,0x18,0x04,0x14,0x94,0x94,0xD5,0xB6,0x14,0x14,0x94,0x04,0x14,0x0C,0x04,0x00,
0x00,0x29,0x29,0x15,0x14,0x4A,0x89,0x44,0x3F,0x06,0x09,0x09,0x10,0x30,0x10,0x00};
uchar code jie[]={0x04,0x04,0x44,0x44,0x44,0x5F,0xC4,0x44,0x44,0x44,0x5F,0x44,0xC4,0x04,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x08,0x10,0x0F,0x00,0x00,0x00};
uchar code ri[]={0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00};
uchar code kuai[]={0x70,0x00,0xFF,0x08,0xB0,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0xF8,0x80,0x80,0x00,
0x00,0x00,0xFF,0x00,0x80,0x40,0x30,0x0E,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00};
uchar code le[]={0x00,0x00,0x40,0xFC,0x44,0x44,0x44,0x46,0xFA,0x42,0x43,0x43,0x42,0x40,0x00,0x00,
0x00,0x20,0x18,0x0C,0x07,0x12,0x20,0x40,0x3F,0x00,0x00,0x02,0x0C,0x38,0x10,0x00};
void delay(uchar z)
{
uchar i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);
}
void checkbusy()
{
uchar dat;
rs=0; //数据指令选择
rw=1; //允许读
do
{
P2=0x00; //清零P2口
delay(5);
e=1;
dat=P2; //读P2口
e=0;
dat>>=7; //仅当第7位为0时才可操作(判别busy信号)
}
while(!(dat==0x00));
}
void write_com(uchar com)
{
checkbusy(); //检查是否忙
rs=0; //写命令
rw=0;
P2=com;
e=1;
e=0;
}
void write_data(uchar date)
{
checkbusy(); //检查是否忙
rs=1; //写数据
rw=0;
P2=date;
e=1;
e=0;
}[page]
void hanzi(uchar ye,uchar lie,uchar *daima)
{
uchar i,j;
for(i=0;i<2;i++)
{
write_com(0xb8+ye+i); // ye页与 ye+1页
write_com(0x40+lie); //确定初始行
for(j=0;j<16;j++)
{
write_data(daima[i*16+j]); //写数据(汉字)
}
}
}
void shuzi(uchar ye,uchar lie,uchar *daima)
{
uchar i,j;
for(i=0;i<2;i++)
{
write_com(0xb8+ye+i); // ye页与 ye+1页
write_com(0x40+lie); //确定初始行
for(j=0;j<8;j++)
{
write_data(daima[i*8+j]); //写数据(数字)
}
}
}
void clearlcd()
{
uchar i,j;
cs1=0; //清全屏 有cs1=0 cs2=0 与无 cs1=0 cs2=0 效果不同
cs2=0;
for(i=0;i<8;i++)
{
write_com(0xb8+i);
write_com(0x40);
for(j=0;j<64;j++)
write_data(0x00);
}
}
void init()
{
write_com(0x3e); //关显示
delay(1);
write_com(0x3f); //开显示
write_com(0xc0); //行初始地址
write_com(0xb8); //页初始地址
write_com(0x40); //列初始地址
}
void display()
{
cs1=0; //左半屏 cs1=0 cs2=1
cs2=1;
hanzi(0,0,liu);
hanzi(0,16,xiao);
hanzi(0,32,jun);
hanzi(0,48,dian);
cs1=1; //右半屏 cs1=1 cs2=0
cs2=0;
hanzi(0,0,zi);
hanzi(0,16,xin);
//hanzi(0,32,kongge); // 如果清屏时加上cs1=0 cs2=0则可以不用,否则要加上
//hanzi(0,48,kongge);
cs1=0;
cs2=1;
hanzi(2,0,xi);
hanzi(2,16,gong);
hanzi(2,32,cheng);
hanzi(2,48,zhuan);
cs1=1;
cs2=0;
hanzi(2,0,ye);
//hanzi(2,16,wang);
//hanzi(2,32,kongge);
//hanzi(2,48,kongge);
cs1=0;
cs2=1;
shuzi(4,0,wu);
shuzi(4,8,er);
shuzi(4,16,ling);
//hanzi(4,32,zhu);
hanzi(4,32,zhu);
hanzi(4,48,yuan);
cs1=1;
cs2=0;
hanzi(4,0,da);
shuzi(4,16,jia);
//hanzi(4,24,jia);
//hanzi(4,40,kongge);
shuzi(4,56,kong);
cs1=0;
cs2=1;
//hanzi(6,0,jia);
hanzi(6,0,jie);
hanzi(6,16,ri);
hanzi(6,32,kuai);
hanzi(6,48,le);
cs1=1;
cs2=0;
//hanzi(6,0,kongge);
//hanzi(6,16,kongge);
//hanzi(6,32,kongge);
//hanzi(6,48,kongge);
}
void main()
{
init();
clearlcd();
while(1)
{
display();
}
}
上一篇:基于51单片机串口通信的实时温度
下一篇:8051软核基本速度比较
推荐阅读最新更新时间:2024-03-16 13:54
设计资源 培训 开发板 精华推荐
- 帮忙他人,成就自我——EEWORLD问答榜(10期)
- ADI有奖下载活动之14 ADI公司针对pH计和电导率仪的演示系统
- 答题有礼 惊喜尽在恩智浦技术中心!
- 关注、评论赢好礼!《美光2022台北国际电脑展主题演讲精选:智能边缘与智能制造专辑》
- 申请ufun学习板,入门&深度学习模拟,工程技能
- 已结束|Maxim IO-Link通信协议设计方案详解,5大优势助你轻松联网!
- 下载有礼|是德科技电子书 《通过了解测试精度的基础知识, 提高良率并降低风险》,不做“差不多先生”
- 有奖直播:借助Maxim的模拟技术优化设计
- 逛村田在线云展厅,看干货,闯关赢好礼!
- 【已结束】直播“戴”“芯”:英飞凌可穿戴设备保姆级解决方案