Altium Designer画的原理图和PCB图如下:(51hei附件中可下载工程文件)
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- void Input595(uchar f);// 寄存到595芯片的输出口
- void Output595(); //输出到点阵
- sbit sclk=P2^0; //数码管HC595第11脚,串行时钟输入端
- sbit sdat=P2^1; //数码管HC595第14脚,串行数据输入端
- sbit cpla=P2^2; //数码管HC595第12脚,输出锁存脉冲输入端
- sbit SHCP_595=P2^3; //点阵HC595第11脚,串行时钟输入端
- sbit DS_595=P2^4; //点阵HC595第14脚,串行数据输入端
- sbit STCP_595=P2^5; //点阵HC595第12脚,输出锁存脉冲输入端
- sbit key1=P1^0; //按键控制数码管加数
- sbit key2=P1^1; //按键控制数码管减数
- sbit key3=P1^2;//控制点阵的显示切换
- unsigned char dis[]={0,1,2,3,4}; //定义显示缓冲区4个单元
- unsigned char code duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- unsigned char code wei[]={0x01,0x02,0x04,0x08};
- char g=0;
- char s=0;
- char b=0;
- char q=0;
- int flog;
- void keya();//数码管按键
- void keyb();//点阵按键
- void delay(uint i) //延时子程序
- {
- while(i--) ;
- }
- void hc595_in(unsigned char Data)
- {
- unsigned char b;
- for(b=0;b<8;b++)
- {
- sdat=Data&0x80;
- Data<<=1;
- sclk=0;
- sclk=1;
- _nop_();
- }
- }
- void hc595_out(void)
- {
- cpla=0;
- _nop_();
- _nop_();
- cpla=1;
- }
- void keya()
- {
- if(key1==0) //如果按键按下
- {
- delay(10000); //消抖
- if(key1==0)
- {
- g++; //个位加一
- if(g>9) //判断是否向十位进位
- {
- s++;
- g=0;
- }
-
- if(s>9) //判断是否向百位进位
- {
- b++;
- s=0;
- }
- if(b>9) //判断是否向百位进位
- {
- q++;
- b=0;
- }
- }
- }
- if(key2==0) //如果按键按下
- {
- delay(10000); //消抖
- if(key2==0) {
- g--; //个位减一
- if(g<0) //判断是否向十位进位
- {
- s--;
- g=9;
- if(s<0) //判断是否向百位进位
- {
- b--;
- s=9;
- if(b<0) //判断是否向百位进位
- {
- q--;
- b=9;
-
- }
- }
- }
- }
- }
- }
- uchar code dz0[]={
- /*-- 文字: 撸 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x84,0x00,0xC4,0x0F,0x24,0x08,0xF4,0x3F,0x2F,0x22,0xE4,0x3F,0x24,0x22,0xE4,0x3F,
- 0x0C,0x00,0xF7,0x7F,0x04,0x00,0xC4,0x1F,0x44,0x10,0xC4,0x1F,0x45,0x10,0xC2,0x1F,
- /*-- 文字: 起 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x00,0x10,0x00,0x10,0x1F,0x7E,0x10,0x10,0x10,0x10,0x10,0x7F,0x1F,0x10,0x11,
- 0x14,0x01,0x14,0x01,0x74,0x21,0x14,0x21,0x14,0x3E,0x1A,0x00,0xF2,0x7F,0x01,0x00,
- /*-- 文字: 袖 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x04,0x04,0x08,0x04,0x00,0x04,0x3F,0x04,0x90,0x3F,0x88,0x24,0x88,0x24,0xAC,0x24,
- 0x9A,0x24,0xA9,0x3F,0xA8,0x24,0x88,0x24,0x88,0x24,0x88,0x24,0x88,0x3F,0x88,0x20,
- /*-- 文字: 子 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFE,0x1F,0x00,0x08,0x00,0x04,0x00,0x02,0x80,0x01,0x80,0x00,0xFF,0x7F,
- 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00,
- /*-- 文字: 加 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x3E,0x7F,0x22,0x48,0x22,0x48,0x22,0x48,0x22,
- 0x48,0x22,0x48,0x22,0x48,0x22,0x48,0x22,0x44,0x22,0x44,0x3E,0x52,0x22,0x21,0x00,
- /*-- 文字: 油 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x02,0x04,0x02,0x08,0x02,0x08,0x02,0xE1,0x3F,0x22,0x22,0x22,0x22,0x28,0x22,
- 0x28,0x22,0xE4,0x3F,0x27,0x22,0x24,0x22,0x24,0x22,0x24,0x22,0xE4,0x3F,0x20,0x20,
- /*-- 文字: 干 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFC,0x1F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0x7F,
- 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
-
- /*-- 文字: ↑ --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x80,0x00,0x80,0x00,0xC0,0x01,0xC0,0x01,0xE0,0x03,0xA0,0x02,0x90,0x04,0x80,0x00,
- 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,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
- };//列代码
- uchar code hdz[32]={0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00,
- 0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80
- };//行代码
- uchar code dz1[]={
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /*-- 文字: 努 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x00,0x08,0x00,0x7F,0x3F,0x44,0x21,0x22,0x11,0x14,0x0A,0x08,0x04,0x14,0x1A,
- 0xA3,0x61,0x40,0x00,0x40,0x00,0xFE,0x1F,0x20,0x10,0x10,0x10,0x08,0x0A,0x06,0x04,
- /*-- 文字: 力 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xFE,0x1F,0x40,0x10,0x40,0x10,0x40,0x10,
- 0x40,0x10,0x20,0x10,0x20,0x10,0x10,0x10,0x10,0x10,0x08,0x11,0x04,0x0A,0x02,0x04,
- /*-- 文字: 努 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x00,0x08,0x00,0x7F,0x3F,0x44,0x21,0x22,0x11,0x14,0x0A,0x08,0x04,0x14,0x1A,
- 0xA3,0x61,0x40,0x00,0x40,0x00,0xFE,0x1F,0x20,0x10,0x10,0x10,0x08,0x0A,0x06,0x04,
- /*-- 文字: 力 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xFE,0x1F,0x40,0x10,0x40,0x10,0x40,0x10,
- 0x40,0x10,0x20,0x10,0x20,0x10,0x10,0x10,0x10,0x10,0x08,0x11,0x04,0x0A,0x02,0x04,
- /*-- 文字: 再 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFF,0x7F,0x80,0x00,0x80,0x00,0xFC,0x1F,0x84,0x10,0x84,0x10,0xFC,0x1F,
- 0x84,0x10,0x84,0x10,0xFF,0x7F,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x14,0x04,0x08,
- /*-- 文字: 努 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x00,0x08,0x00,0x7F,0x3F,0x44,0x21,0x22,0x11,0x14,0x0A,0x08,0x04,0x14,0x1A,
- 0xA3,0x61,0x40,0x00,0x40,0x00,0xFE,0x1F,0x20,0x10,0x10,0x10,0x08,0x0A,0x06,0x04,
- /*-- 文字: 力 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xFE,0x1F,0x40,0x10,0x40,0x10,0x40,0x10,
- 0x40,0x10,0x20,0x10,0x20,0x10,0x10,0x10,0x10,0x10,0x08,0x11,0x04,0x0A,0x02,0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 Input595(uchar f)
- {
- uchar i;
- for (i=0; i<8; i++)
- {
- DS_595 = f>>7 ;
- f <<= 1;
- SHCP_595=0;
- _nop_();
- SHCP_595=1;
- }
- }
- void Output595()
- {
- STCP_595 = 0;
- _nop_();
- STCP_595 = 1;
- STCP_595 = 0;
- }
- void keyb()
- {
- if(key3==0)
- {
- delay(250);
- if(key3==0)
- {
- flog++;
- if(flog==2)
- {
- flog=0;
- }
- }
- while(!key3);
- }
- }
- //主函数
- void main()
- {
- unsigned char e;
- unsigned char p;
- uint a,i,j,n;
- while(1)
- {
- a=0;
- for(j=0;j<128;j++)//总共需要128屏
- {
- n=a;
- for(i=0;i<16;i++)//输出1屏
- {
- for(e=0;e<4;e++)
- {
- keya();
- switch(e)
- {
- case 0:p=q;break;
- case 1:p=b;break;
- case 2:p=s;break;
- case 3:p=g;break;
- }
- hc595_in(wei[e]);
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
项目三.7z
(710.37 KB, 下载次数: 114)
|