8*8点阵仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg52.h>
- #define uchar unsigned char //宏定义
- code uchar jiantou[]={0x00,0x18,0x3C,0x7E,0x99,0x18,0x18,0x00,0x00,0x18,0x3C,0x7E,0x99,0x18,0x18,0x00,0x00,0x18,0x3C,0x7E,0x99,0x18,0x18,0x00,0x00,0x18,0x3C,0x7E,0x99,0x18,0x18,0x00};
- code uchar ling[]={0x00,0x7C,0x44,0x44,0x44,0x44,0x44,0x7C};//定义数组 0
- code uchar yi[]={0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04};//定义数组 1
- code uchar er[]={0x00,0x7C,0x04,0x04,0x7C,0x40,0x40,0x7C};//定义数组 2
- code uchar san[]={0x00,0x7C,0x04,0x04,0x7C,0x04,0x04,0x7C};//定义数组 3
- code uchar si[]={0x00,0x44,0x44,0x44,0x7C,0x04,0x04,0x04};//定义数组 4
- code uchar wu[]={0x00,0x7C,0x40,0x40,0x7C,0x04,0x04,0x7C};//定义数组 5
- code uchar liu[]={0x00,0x7C,0x40,0x40,0x7C,0x44,0x44,0x7C};//定义数组 6
- code uchar qi[]={0x00,0x3C,0x04,0x04,0x04,0x04,0x04,0x04};//定义数组 7
- code uchar ba[]={0x00,0x7C,0x44,0x44,0x7C,0x44,0x44,0x7C};//定义数组 8
- code uchar jiu[]={0x00,0x7C,0x44,0x44,0x7C,0x04,0x04,0x7C};//定义数组 9
- code uchar xin[]={0x00,0x66,0x99,0x81,0x81,0x42,0x24,0x18};//定义数组 心
- code uchar sanjiao[]={0x00,0x00,0x10,0x28,0x44,0xFE,0x00,0x00};//定义数组 三角
- code uchar zhang[]={0xE9,0x2A,0xEC,0x9F,0xEC,0x2A,0xED,0x00};//定义数组 “张”
- code uchar f[]={0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x40};//定义数组 字母“F”
- sbit P20=P2^7;
- unsigned char date=0;
- int i;
- uchar b;
- void delay()//延时函数
- {
- for(i=0;i<50;i++);
- }
- void zuoyi()
- {
- int i,a,b,c;
- for(a=0;a<24;a++)
- {for(b=0;b<50;b++)
- {
- P3=0xfe; //行控制
- for(c=0;c<8;c++)//扫描一针取八个数据
- {
- P1=jiantou[a+c];//a+c表示第a针第c列
- delay();
- P3=P3<<7|P3>>1;
- }
- }
- }
- }
- void youyi()
- {
- int i,a,b,c;
- for(a=0;a<24;a++)
- {for(b=0;b<50;b++)
- {
- P3=0xfe; //行控制
- for(c=0;c<8;c++)//扫描一针取八个数据
- {
- P1=jiantou[a+c];//a+c表示第a针第c列
- delay();
- P3=P3<<1|P3>>7;
- }
- }
- }
- }
- void xiayi()
- {
- int i,a,b,c;
- for(a=0;a<24;a++)
- {for(b=0;b<50;b++)
- {
- P1=~0xfe; //行控制
- for(c=0;c<8;c++)//扫描一针取八个数据
- {
- P3=~jiantou[a+c];//a+c表示第a针第c列
- delay();
- P1=P1<<7|P1>>1;
- }
- }
- }
- }
- void shangyi()
- {
- int i,a,b,c;
- for(a=0;a<24;a++)
- {for(b=0;b<50;b++)
- {
- P1=~0xfe; //行控制
- for(c=0;c<8;c++)//扫描一针取八个数据
- {
- P3=~jiantou[a+c];//a+c表示第a针第c列
- delay();
- P1=P1<<1|P1>>7;
- }
- }
- }
- }
- void anjian()
- {
- P1=~0xfe; //行控制
- for(b=0;b<8;b++)//循环数组内容
- {
- if(P20==0)
- {
- date++;
- while(!P20);
- }
- switch(date)
- {
- case 0:P3=~ling[b]; break;
- case 1:P3=~yi[b]; break;
- case 2:P3=~er[b]; break;
- case 3:P3=~san[b]; break;
- case 4:P3=~si[b]; break;
- case 5:P3=~wu[b]; break;
- case 6:P3=~liu[b]; break;
- case 7:P3=~qi[b]; break;
- case 8:P3=~ba[b]; break;
- case 9:P3=~jiu[b]; break;
- case 10:P3=~xin[b]; break;
- case 11:P3=~sanjiao[b]; break;
- case 12:P3=~zhang[b]; break;
- case 13:P3=~f[b]; break;
- case 14:date=0; break;
- }
- delay();
- P1=P1<<1|P1>>7;
- }
- }
- main()
- {
- shangyi();
- xiayi();
- zuoyi();
- youyi();
- while(1)
- {
- anjian();
- }
- }
复制代码
所有资料51hei提供下载:
8X8点阵.rar
(54.3 KB, 下载次数: 50)
|