//包含头文件//显示模式
unsigned char mode0,mode1,mode2,mode3,mode4; sbit k1=P2^7; sbit k2=P2^6; sbit k3=P2^5; sbit k4=P2^4; sbit k5=P2^0;
unsigned char xin1[8]={
0x0,0x0,0x0,0x6C,0x92,0x44,0x28,0x10 };//心形1
unsigned char bxin1[8]={
0x0,0x0,0x0,0x6C,0x82,0x0,0x28,0x10 };//半心形1
unsigned char xin2[8]={
0x0,0x36,0x49,0x22,0x14,0x8,0x0,0x0 };//心形2
unsigned char bxin2[8]={
0x0,0x36,0x41,0x0,0x14,0x8,0x0,0x0 };//半心形2 unsigned char xin[8]={
0x0,0x36,0x41,0x6E,0x96,0x4C,0x28,0x10
文案
标准
};//双心形2
unsigned char zimu0[8]={
0x38,0x24,0x22,0x22,0x22,0x22,0x24,0x38 };//D
unsigned char zimu1[8]={
0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C };//I
unsigned char zimu2[8]={
0x1E,0x20,0x40,0x40,0x4E,0x42,0x22,0x1E };//G
unsigned char zimu3[8]={
0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C };//I
unsigned char zimu4[8]={
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3E };//L
unsigned char zimu5[8]={
0x7E,0x40,0x40,0x7E,0x7E,0x40,0x40,0x7E
文案
标准
};//E
unsigned char zimu6[8]={
0x0,0x42,0x62,0x52,0x4A,0x46,0x42,0x0 };//N
unsigned char zimu7[8]={
0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18 };//T
unsigned char name0[8]={
0xE9,0x2A,0xEC,0x9F,0xE8,0x2C,0x6A,0x29 };//张
unsigned char name1[8]={
0x42,0x24,0x7E,0x0,0x3C,0x0,0xFF,0x0 };//兰
unsigned char name2[8]={
0x26,0x74,0x25,0xFE,0x56,0x55,0x56,0x94 };//郝
unsigned char ai0[8]={
0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C };//I
文案
标准
unsigned char ai1[8]={
0x0,0x66,0xFF,0xFF,0x7E,0x3C,0x18,0x0 };//实心
unsigned char ai2[8]={
0x0,0x66,0x99,0x81,0x42,0x24,0x18,0x0 };//空心
unsigned char ai3[8]={
0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C };//U
unsigned char xie0[8]={
0x0,0x3E,0x8,0x8,0x8,0x8,0x8,0x0 };//T
unsigned char xie1[8]={
0x0,0x24,0x24,0x24,0x3C,0x24,0x24,0x24 };//H
unsigned char xie2[8]={
0x0,0x8,0x14,0x3E,0x41,0x41,0x0,0x0 };//A
unsigned char xie3[8]={
0x0,0x0,0x22,0x26,0x2A,0x32,0x22,0x0
文案
标准
};//N
unsigned char xie4[8]={
0x22,0x24,0x28,0x30,0x28,0x24,0x22,0x0 };//K
unsigned char xie5[8]={
0x1C,0x22,0x20,0x10,0xC,0x2,0x22,0x1C };//S
void delay() { }
void main(void) {
文案
//延时函数
unsigned int c; c=300; while(c--){}
//主函数
unsigned int i,j,k,m; k1=1; k2=1; k3=1;
标准
k4=1; k5=1; m=10; mode0=0; for(k=0;k<8;k++) {
for(j=0;j<30;j++) //调节字母变化速度 for(i=0;i<8;i++)
//点阵8列动态扫描法显示,每次扫
描一列并发送数据码 {
if(mode0==0)
//模式0-3分别对应4种表情,根
据模式选择表情所对应的显示码
文案
P0=zimu0[i];
if(mode0==1)
P0=zimu1[i];
if(mode0==2)
P0=zimu2[i];
if(mode0==3)
P0=zimu3[i];
if(mode0==4)
P0=zimu4[i];
if(mode0==5)
标准
P0=zimu5[i];
if(mode0==6)
P0=zimu6[i];
if(mode0==7)
P0=zimu7[i];
P1=~(1<delay();
//延时
}
mode0++; if(mode0>7)
mode0=0;
}
P0=0; //P0口各脚输出高电平,点阵不显示 while(1) { mode1=0; mode2=0; mode3=0;
mode4=0;
if(k5==0)
文案
标准
{ }
while(!k5);//松手检测 //delay(5); if(k4==0) //消抖 { }
m=m+30; if(m>100)
m=10;
while(k1==0) //图形1 {
for(j=0;j//点阵8列动态扫描法显示,每次扫描一列并发送数据码 {
if(mode1==0)
//模式0-3分别对应4种表情,根
据模式选择表情所对应的显示码
文案
P0=bxin1[i];
if(mode1==1)
P0=xin1[i];
标准
}
}
if(mode1==2)
P0=bxin2[i];
if(mode1==3)
P0=xin2[i];
if(mode1==4)
P0=xin[i];
//扫描该列
P1=~(1<//延时
mode1++; if(mode1>4)
mode1=0;
while(k2==0) //图形2 {
for(j=0;j//点阵8列动态扫描法显示,每次扫描一列并发送数据码 {
if(mode2==0)
//模式0-3分别对应4种表情,根
据模式选择表情所对应的显示码
文案
P0=name0[i];
标准
}
}
if(mode2==1)
P0=name1[i];
if(mode2==2)
P0=name2[i];
P1=~(1<//扫描该列
//延时
mode2++; if(mode2>2)
mode2=0;
while(k3==0) //图形3 {
for(j=0;j//点阵8列动态扫描法显示,每次扫描一列并发送数据码 {
if(mode3==0)
//模式0-3分别对应4种表情,根
据模式选择表情所对应的显示码
文案
P0=ai0[i];
if(mode3==1)
P0=ai1[i];
标准
}
}
if(mode3==2)
P0=ai2[i];
if(mode3==3)
P0=ai3[i];
//扫描该列
P1=~(1<//延时
mode3++; if(mode3>3)
mode3=0;
while(k4==0) //图形4 {
for(j=0;j<20;j++) //调节表情变化速度 for(i=0;i<8;i++)
//点阵8列动态扫描法显示,每次扫
描一列并发送数据码 {
if(mode4==0)
//模式0-3分别对应4种表情,根
据模式选择表情所对应的显示码
文案
P0=xie0[i];
if(mode4==1)
P0=xie1[i];
标准
if(mode4==2)
P0=xie2[i];
if(mode4==3)
P0=xie3[i];
if(mode4==4)
P0=xie4[i];
if(mode4==5)
P0=xie5[i];
P1=~(1<} mode4++; if(mode4>5)
mode4=0;
}
P0=0X00; P1=0XFF;
}
}
文案
//扫描该列//延时