专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
51单片机
想学习一下如何把两个程序合在一起?
2019-07-16 04:59
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
51单片机
3573
16
1673
在下新手,刚入道,想学习一下如何把两个程序合在一起?
在keil里面操作!两个程序融合需要怎样操作呢?
请前辈们指点!
谢谢!
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
16条回答
pnsyzx20088hlq
1楼-- · 2019-07-17 18:35
嗯 谢谢大家的支持!我再仔细摸索一番!
加载中...
holybob
2楼-- · 2019-07-17 22:52
搭车学习,谢谢啦~
加载中...
zwa7788
3楼-- · 2019-07-17 22:55
#include "STC12C5A.H"
#include <INTRINS.H> //包含延时头文件
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_();_nop_();
sbit AD=P1^0; //定义音频输入接口
sbit K1=P1^2; //定义功能按键接口
sbit K2=P1^4; //定义功能按键接口
sbit K3=P1^5; //定义功能按键接口
sbit K4=P1^7; //定义功能按键接口
sbit K5=P3^6; //定义功能按键接口
sbit K6=P3^5; //定义功能按键接口
sbit K7=P3^2; //定义功能按键接口
sbit K8=P3^4; //定义功能按键接口
sbit L1=P0^3; sbit L2=P4^5; sbit L3=P2^4; sbit L4=P2^2; sbit H1=P0^5;
sbit L5=P0^1; sbit L6=P4^6; sbit L7=P2^7; sbit L8=P2^0; sbit H2=P0^6;
sbit L9=P0^0; sbit L10=P0^7; sbit L11=P2^6; sbit L12=P1^6; sbit H3=P4^4;
sbit L13=P1^3; sbit L14=P0^4; sbit L15=P2^5; sbit L16=P3^3; sbit H4=P2^3;
sbit H5=P4^7;
//定义光立方的接口全部高电平有效
sbit LED1=P0^2; sbit LED2=P2^1;
sbit LED3=P3^7; sbit LED4=P1^1;
//定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效
unsigned char bdata dzzc0;
sbit dzzc07=dzzc0^7;
sbit dzzc06=dzzc0^6;
sbit dzzc05=dzzc0^5;
sbit dzzc04=dzzc0^4;
sbit dzzc03=dzzc0^3;
sbit dzzc02=dzzc0^2;
sbit dzzc01=dzzc0^1;
sbit dzzc00=dzzc0^0;
unsigned char bdata dzzc1;
sbit dzzc17=dzzc1^7;
sbit dzzc16=dzzc1^6;
sbit dzzc15=dzzc1^5;
sbit dzzc14=dzzc1^4;
sbit dzzc13=dzzc1^3;
sbit dzzc12=dzzc1^2;
sbit dzzc11=dzzc1^1;
sbit dzzc10=dzzc1^0;
unsigned char bdata dzzc2;
sbit dzzc27=dzzc2^7;
sbit dzzc26=dzzc2^6;
sbit dzzc25=dzzc2^5;
sbit dzzc24=dzzc2^4;
sbit dzzc23=dzzc2^3;
sbit dzzc22=dzzc2^2;
sbit dzzc21=dzzc2^1;
sbit dzzc20=dzzc2^0;
unsigned char bdata dzzc3;
sbit dzzc37=dzzc3^7;
sbit dzzc36=dzzc3^6;
sbit dzzc35=dzzc3^5;
sbit dzzc34=dzzc3^4;
sbit dzzc33=dzzc3^3;
sbit dzzc32=dzzc3^2;
sbit dzzc31=dzzc3^1;
sbit dzzc30=dzzc3^0;
//调整数字显示的数据用分别为变的1234
// 4 dzzc6
//3 2 dzzc7 dzzc5
// 1 dzzc4
unsigned char bdata dzzc4;
sbit dzzc47=dzzc4^7;
sbit dzzc46=dzzc4^6;
sbit dzzc45=dzzc4^5;
sbit dzzc44=dzzc4^4;
sbit dzzc43=dzzc4^3;
sbit dzzc42=dzzc4^2;
sbit dzzc41=dzzc4^1;
sbit dzzc40=dzzc4^0;
unsigned char bdata dzzc5;
sbit dzzc57=dzzc5^7;
sbit dzzc56=dzzc5^6;
sbit dzzc55=dzzc5^5;
sbit dzzc54=dzzc5^4;
sbit dzzc53=dzzc5^3;
sbit dzzc52=dzzc5^2;
sbit dzzc51=dzzc5^1;
sbit dzzc50=dzzc5^0;
unsigned char bdata dzzc6;
sbit dzzc67=dzzc6^7;
sbit dzzc66=dzzc6^6;
sbit dzzc65=dzzc6^5;
sbit dzzc64=dzzc6^4;
sbit dzzc63=dzzc6^3;
sbit dzzc62=dzzc6^2;
sbit dzzc61=dzzc6^1;
sbit dzzc60=dzzc6^0;
unsigned char bdata dzzc7;
sbit dzzc77=dzzc7^7;
sbit dzzc76=dzzc7^6;
sbit dzzc75=dzzc7^5;
sbit dzzc74=dzzc7^4;
sbit dzzc73=dzzc7^3;
sbit dzzc72=dzzc7^2;
sbit dzzc71=dzzc7^1;
sbit dzzc70=dzzc7^0;
unsigned int CYCLE=100,PWM_LOW=1110,shan=0,saom=0,shuzi1,shuzi2=0,shuzi3=0,shuzi4=0;//定义周期并赋值
unsigned char YL1=0,YL2=0,YL3=0,YL4=0,YL5=0,YL6=0,YL7=0,YL8=0,YL9=0,YL10=0,YL11=0,YL12=0,YL13=0,YL14=0,YL15=0,YL16=0;//高度值
unsigned char lie=0,hang=0,ceng=0,keyy,keyc,keyx;
unsigned int donghua=0,nehx;
unsigned char yinyue4X4[]= //定义4X4X4整个屏幕的显示数据,高电平有效,没有音乐的时候默认不亮
{
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
};
unsigned char code shuzu4X4[]= //定义4X4X4整个屏幕的显示数据,根据取字模软件进行提取高电平有效
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//0帧
0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//1帧
0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//2帧
0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//3帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//4帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//5帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//6帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//7帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//8帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//9帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//10帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//11帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//12帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,//13帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,//14帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,//15帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//16帧
0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//17帧
0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//18帧
0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//19帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//20帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//21帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//22帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//23帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//24帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,//25帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,//26帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,//27帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,//28帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,//29帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,//30帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,//31帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,//32帧
};
void Delay(unsigned int t)
{ unsigned char a;
for(a=t;a>0;a--);
_nop_(); //if Keil,require use intrins.h
}
void init()
{
P4SW=0xff; //定义P4口为I/O口
P0M1=0x00; //I/O口0模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
P0M0=0xff; //定义P0为强上拉输出.
P1M1=0x01;
P1M0=0x4a; //定义P1为强上拉输出. P.14作为AD此时不能作为强上蜡
P2M1=0x00;
P2M0=0xff; //定义P2为强上拉输出.
P3M1=0x00;
P3M0=0x88; //定义P3为强上拉输出.
P4M1=0x00;
P4M0=0xff; //定义P4为强上拉输出.
}
void hansao(unsigned char hs,unsigned char shangxia)
{
if(shangxia==0)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //作为控制显示高度的时候调用
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
}
}
else if(shangxia==1)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //平时的时候调用这个显示其他图形和变化
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
}
}
}
void KEYSCAN(void)
{
if(K1==0&&K2==0&&K3==0&&K4==0&&K5==0){keyy=0;} //00000 0 //全灭
else if(K1==0&&K2==0&&K3==0&&K4==0&&K5==1){keyy=1;} //00001 1
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==0){keyy=2;} //00010 2
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==1){keyy=3;} //00011 3
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==0){keyy=4;} //00100 4
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==1){keyy=5;} //00101 5
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==0){keyy=6;} //00110 6
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==1){keyy=7;} //00111 7
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==0){keyy=8;} //01000 8
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==1){keyy=9;} //01001 9
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==0){keyy=10;} //01010 10
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==1){keyy=11;} //01011 11
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==0){keyy=12;} //01100 12
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==1){keyy=13;} //01101 13
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==0){keyy=14;} //01110 14
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==1){keyy=15;} //01111 15
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==0){keyy=16;} //10000 16
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==1){keyy=17;} //10001 17
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==0){keyy=18;} //10010 18
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==1){keyy=19;} //10011 19
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==0){keyy=20;} //10100 20
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==1){keyy=21;} //10101 21
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==0){keyy=22;} //10110 22
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==1){keyy=23;} //10111 23
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==0){keyy=24;} //11000 24
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==1){keyy=25;} //11001 25
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==0){keyy=26;} //11010 26
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==1){keyy=27;} //11011 27
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==0){keyy=28;} //11100 28
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==1){keyy=29;} //11101 29
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==0){keyy=30;} //11110 30
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==1){keyy=31;} //11111 31
else if(K6==0&&K7==0&&K8==0){keyc=128;} //000 0 //30分钟
else if(K6==0&&K7==0&&K8==1){keyc=64;} //001 1
else if(K6==0&&K7==1&&K8==0){keyc=32;} //010 2
else if(K6==0&&K7==1&&K8==1){keyc=16;} //011 3
else if(K6==1&&K7==0&&K8==0){keyc=8;} //100 4
else if(K6==1&&K7==0&&K8==1){keyc=4;} //101 5
else if(K6==1&&K7==1&&K8==0){keyc=2;} //110 6
else if(K6==1&&K7==1&&K8==1){keyc=1;} //111 7
}
void disp1(void)
{
for(CYCLE=0;CYCLE<1000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
void disp(unsigned char sj)
{
for(shuzi1=0;shuzi1<sj;shuzi1++)
{
for(nehx=0;nehx<14;nehx++) //14
{
for(CYCLE=0;CYCLE<6000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
}
}
void main()
{
init(); //初始化IO口为强上蜡输出状态
LED1=0; LED2=0;
LED3=0; LED4=0; //测试底部4个LED关闭
K1=1;
K2=1;
K3=1;
K4=1;
K5=1;
K6=1;
K7=1;
K8=1;
while (1)
{
KEYSCAN();
if(keyy==0)
{keyx=keyy;
while(1){
donghua=keyy;
disp1();
KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==1)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==2)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==3)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==4)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==5)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==6)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==7)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==8)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==9)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==10)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==11)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==12)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==13)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==14)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==15)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==16)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==17)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==18)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==19)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==20)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==21)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==22)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==23)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==24)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==25)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==26)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==27)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==28)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==29)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==30)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==31)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
}
}
上面的代码和下面的能不能整合到一起啊
#include <reg51.h>
#include <intrins.h>
unsigned char key_s, key_v, tmp,tmp2,tmp3;
void send_str();
void delayms(unsigned int ms);
void send_char(unsigned char txd);
main()
{
TMOD = 0x20; // 定时器1工作于8位自动重载模式, 用于产生波特率
TH1 = 0xFD; // 波特率9600
TL1 = 0xFD;
SCON = 0x50; // 设定串行口工作方式
PCON &= 0xef; // 波特率不倍增
TR1 = 1; // 启动定时器1
IE = 0x0; // 禁止任何中断
while(1)
{
if(RI) // 是否有数据到来
{
RI = 0;
tmp = SBUF;
if (tmp==224){
send_str(); //将四个p口发给串口
} else {
if (tmp==225 || tmp==226 || tmp==227 || tmp==228 )
{
tmp2=tmp;
} else {
if (tmp2==225){
P0=tmp;
//send_str();
}
if (tmp2==226){
P1=tmp;
// send_str();
}
if ( tmp2==227){
P2=tmp;
// send_str();
}
if (tmp2==228){
P3=tmp;
}
}
}
}
delayms(25000);//延时1毫秒
}
}
void send_str()
// 传送字串
{
SBUF =224;
while(!TI);
TI = 0;
tmp3=P0;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P1;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P2;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P3;
SBUF = tmp3;
while(!TI);
TI = 0;
SBUF = 225;
while(!TI);
TI = 0;
}
void delayms(unsigned int i)//汇编后是DJNZ指令用2微秒 (双机器周期) 参数在65535以下
{
i=i/2;
while(--i);
}
以上两盒源码怎么整合到一起
加载中...
zwa7788
4楼-- · 2019-07-18 00:39
#include <reg51.h>
#include <intrins.h>
unsigned char key_s, key_v, tmp,tmp2,tmp3;
void send_str();
void delayms(unsigned int ms);
void send_char(unsigned char txd);
main()
{
TMOD = 0x20; // 定时器1工作于8位自动重载模式, 用于产生波特率
TH1 = 0xFD; // 波特率9600
TL1 = 0xFD;
SCON = 0x50; // 设定串行口工作方式
PCON &= 0xef; // 波特率不倍增
TR1 = 1; // 启动定时器1
IE = 0x0; // 禁止任何中断
while(1)
{
if(RI) // 是否有数据到来
{
RI = 0;
tmp = SBUF;
if (tmp==224){
send_str(); //将四个p口发给串口
} else {
if (tmp==225 || tmp==226 || tmp==227 || tmp==228 )
{
tmp2=tmp;
} else {
if (tmp2==225){
P0=tmp;
//send_str();
}
if (tmp2==226){
P1=tmp;
// send_str();
}
if ( tmp2==227){
P2=tmp;
// send_str();
}
if (tmp2==228){
P3=tmp;
}
}
}
}
delayms(25000);//延时1毫秒
}
}
void send_str()
// 传送字串
{
SBUF =224;
while(!TI);
TI = 0;
tmp3=P0;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P1;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P2;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P3;
SBUF = tmp3;
while(!TI);
TI = 0;
SBUF = 225;
while(!TI);
TI = 0;
}
void delayms(unsigned int i)//汇编后是DJNZ指令用2微秒 (双机器周期) 参数在65535以下
{
i=i/2;
while(--i);
}
这个代码和下面的代码,可以整合到一起吗?
#include "STC12C5A.H"
#include <INTRINS.H> //包含延时头文件
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_();_nop_();
sbit AD=P1^0; //定义音频输入接口
sbit K1=P1^2; //定义功能按键接口
sbit K2=P1^4; //定义功能按键接口
sbit K3=P1^5; //定义功能按键接口
sbit K4=P1^7; //定义功能按键接口
sbit K5=P3^6; //定义功能按键接口
sbit K6=P3^5; //定义功能按键接口
sbit K7=P3^2; //定义功能按键接口
sbit K8=P3^4; //定义功能按键接口
sbit L1=P0^3; sbit L2=P4^5; sbit L3=P2^4; sbit L4=P2^2; sbit H1=P0^5;
sbit L5=P0^1; sbit L6=P4^6; sbit L7=P2^7; sbit L8=P2^0; sbit H2=P0^6;
sbit L9=P0^0; sbit L10=P0^7; sbit L11=P2^6; sbit L12=P1^6; sbit H3=P4^4;
sbit L13=P1^3; sbit L14=P0^4; sbit L15=P2^5; sbit L16=P3^3; sbit H4=P2^3;
sbit H5=P4^7;
//定义光立方的接口全部高电平有效
sbit LED1=P0^2; sbit LED2=P2^1;
sbit LED3=P3^7; sbit LED4=P1^1;
//定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效
unsigned char bdata dzzc0;
sbit dzzc07=dzzc0^7;
sbit dzzc06=dzzc0^6;
sbit dzzc05=dzzc0^5;
sbit dzzc04=dzzc0^4;
sbit dzzc03=dzzc0^3;
sbit dzzc02=dzzc0^2;
sbit dzzc01=dzzc0^1;
sbit dzzc00=dzzc0^0;
unsigned char bdata dzzc1;
sbit dzzc17=dzzc1^7;
sbit dzzc16=dzzc1^6;
sbit dzzc15=dzzc1^5;
sbit dzzc14=dzzc1^4;
sbit dzzc13=dzzc1^3;
sbit dzzc12=dzzc1^2;
sbit dzzc11=dzzc1^1;
sbit dzzc10=dzzc1^0;
unsigned char bdata dzzc2;
sbit dzzc27=dzzc2^7;
sbit dzzc26=dzzc2^6;
sbit dzzc25=dzzc2^5;
sbit dzzc24=dzzc2^4;
sbit dzzc23=dzzc2^3;
sbit dzzc22=dzzc2^2;
sbit dzzc21=dzzc2^1;
sbit dzzc20=dzzc2^0;
unsigned char bdata dzzc3;
sbit dzzc37=dzzc3^7;
sbit dzzc36=dzzc3^6;
sbit dzzc35=dzzc3^5;
sbit dzzc34=dzzc3^4;
sbit dzzc33=dzzc3^3;
sbit dzzc32=dzzc3^2;
sbit dzzc31=dzzc3^1;
sbit dzzc30=dzzc3^0;
//调整数字显示的数据用分别为变的1234
// 4 dzzc6
//3 2 dzzc7 dzzc5
// 1 dzzc4
unsigned char bdata dzzc4;
sbit dzzc47=dzzc4^7;
sbit dzzc46=dzzc4^6;
sbit dzzc45=dzzc4^5;
sbit dzzc44=dzzc4^4;
sbit dzzc43=dzzc4^3;
sbit dzzc42=dzzc4^2;
sbit dzzc41=dzzc4^1;
sbit dzzc40=dzzc4^0;
unsigned char bdata dzzc5;
sbit dzzc57=dzzc5^7;
sbit dzzc56=dzzc5^6;
sbit dzzc55=dzzc5^5;
sbit dzzc54=dzzc5^4;
sbit dzzc53=dzzc5^3;
sbit dzzc52=dzzc5^2;
sbit dzzc51=dzzc5^1;
sbit dzzc50=dzzc5^0;
unsigned char bdata dzzc6;
sbit dzzc67=dzzc6^7;
sbit dzzc66=dzzc6^6;
sbit dzzc65=dzzc6^5;
sbit dzzc64=dzzc6^4;
sbit dzzc63=dzzc6^3;
sbit dzzc62=dzzc6^2;
sbit dzzc61=dzzc6^1;
sbit dzzc60=dzzc6^0;
unsigned char bdata dzzc7;
sbit dzzc77=dzzc7^7;
sbit dzzc76=dzzc7^6;
sbit dzzc75=dzzc7^5;
sbit dzzc74=dzzc7^4;
sbit dzzc73=dzzc7^3;
sbit dzzc72=dzzc7^2;
sbit dzzc71=dzzc7^1;
sbit dzzc70=dzzc7^0;
unsigned int CYCLE=100,PWM_LOW=1110,shan=0,saom=0,shuzi1,shuzi2=0,shuzi3=0,shuzi4=0;//定义周期并赋值
unsigned char YL1=0,YL2=0,YL3=0,YL4=0,YL5=0,YL6=0,YL7=0,YL8=0,YL9=0,YL10=0,YL11=0,YL12=0,YL13=0,YL14=0,YL15=0,YL16=0;//高度值
unsigned char lie=0,hang=0,ceng=0,keyy,keyc,keyx;
unsigned int donghua=0,nehx;
unsigned char yinyue4X4[]= //定义4X4X4整个屏幕的显示数据,高电平有效,没有音乐的时候默认不亮
{
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
};
unsigned char code shuzu4X4[]= //定义4X4X4整个屏幕的显示数据,根据取字模软件进行提取高电平有效
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//0帧
0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//1帧
0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//2帧
0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//3帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//4帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//5帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//6帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//7帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//8帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//9帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//10帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//11帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//12帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,//13帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,//14帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,//15帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//16帧
0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//17帧
0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//18帧
0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//19帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//20帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//21帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//22帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//23帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//24帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,//25帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,//26帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,//27帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,//28帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,//29帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,//30帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,//31帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,//32帧
};
void Delay(unsigned int t)
{ unsigned char a;
for(a=t;a>0;a--);
_nop_(); //if Keil,require use intrins.h
}
void init()
{
P4SW=0xff; //定义P4口为I/O口
P0M1=0x00; //I/O口0模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
P0M0=0xff; //定义P0为强上拉输出.
P1M1=0x01;
P1M0=0x4a; //定义P1为强上拉输出. P.14作为AD此时不能作为强上蜡
P2M1=0x00;
P2M0=0xff; //定义P2为强上拉输出.
P3M1=0x00;
P3M0=0x88; //定义P3为强上拉输出.
P4M1=0x00;
P4M0=0xff; //定义P4为强上拉输出.
}
void hansao(unsigned char hs,unsigned char shangxia)
{
if(shangxia==0)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //作为控制显示高度的时候调用
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
}
}
else if(shangxia==1)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //平时的时候调用这个显示其他图形和变化
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
}
}
}
void KEYSCAN(void)
{
if(K1==0&&K2==0&&K3==0&&K4==0&&K5==0){keyy=0;} //00000 0 //全灭
else if(K1==0&&K2==0&&K3==0&&K4==0&&K5==1){keyy=1;} //00001 1
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==0){keyy=2;} //00010 2
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==1){keyy=3;} //00011 3
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==0){keyy=4;} //00100 4
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==1){keyy=5;} //00101 5
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==0){keyy=6;} //00110 6
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==1){keyy=7;} //00111 7
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==0){keyy=8;} //01000 8
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==1){keyy=9;} //01001 9
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==0){keyy=10;} //01010 10
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==1){keyy=11;} //01011 11
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==0){keyy=12;} //01100 12
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==1){keyy=13;} //01101 13
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==0){keyy=14;} //01110 14
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==1){keyy=15;} //01111 15
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==0){keyy=16;} //10000 16
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==1){keyy=17;} //10001 17
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==0){keyy=18;} //10010 18
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==1){keyy=19;} //10011 19
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==0){keyy=20;} //10100 20
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==1){keyy=21;} //10101 21
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==0){keyy=22;} //10110 22
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==1){keyy=23;} //10111 23
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==0){keyy=24;} //11000 24
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==1){keyy=25;} //11001 25
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==0){keyy=26;} //11010 26
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==1){keyy=27;} //11011 27
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==0){keyy=28;} //11100 28
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==1){keyy=29;} //11101 29
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==0){keyy=30;} //11110 30
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==1){keyy=31;} //11111 31
else if(K6==0&&K7==0&&K8==0){keyc=128;} //000 0 //30分钟
else if(K6==0&&K7==0&&K8==1){keyc=64;} //001 1
else if(K6==0&&K7==1&&K8==0){keyc=32;} //010 2
else if(K6==0&&K7==1&&K8==1){keyc=16;} //011 3
else if(K6==1&&K7==0&&K8==0){keyc=8;} //100 4
else if(K6==1&&K7==0&&K8==1){keyc=4;} //101 5
else if(K6==1&&K7==1&&K8==0){keyc=2;} //110 6
else if(K6==1&&K7==1&&K8==1){keyc=1;} //111 7
}
void disp1(void)
{
for(CYCLE=0;CYCLE<1000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
void disp(unsigned char sj)
{
for(shuzi1=0;shuzi1<sj;shuzi1++)
{
for(nehx=0;nehx<14;nehx++) //14
{
for(CYCLE=0;CYCLE<6000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
}
}
void main()
{
init(); //初始化IO口为强上蜡输出状态
LED1=0; LED2=0;
LED3=0; LED4=0; //测试底部4个LED关闭
K1=1;
K2=1;
K3=1;
K4=1;
K5=1;
K6=1;
K7=1;
K8=1;
while (1)
{
KEYSCAN();
if(keyy==0)
{keyx=keyy;
while(1){
donghua=keyy;
disp1();
KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==1)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==2)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==3)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==4)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==5)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==6)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==7)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==8)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==9)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==10)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==11)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==12)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==13)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==14)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==15)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==16)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==17)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==18)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==19)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==20)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==21)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==22)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==23)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==24)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==25)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==26)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==27)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==28)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==29)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==30)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==31)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
}
}
加载中...
上一页
1
2
3
一周热门
更多
>
相关问题
【东软载波ESF0654 PDS开发板活动】开箱
1 个回答
东软载波ESF0654 PDS开发板外部中断
1 个回答
东软载波ESF0654 PDS开发板高级控制定时器AD16C4T
1 个回答
用串口调试助手为什么只能在hex模式接收发送而在文本模式不行
9 个回答
触摸芯片SC02B/SC04B在地砖灯的设计方案
1 个回答
东软载波ESF0654 PDS开发板串口USART0代码分享
1 个回答
普通32位单片机使用linux的应用代码
5 个回答
东软载波ESF0654 PDS开发板AT24C04的调试
9 个回答
相关文章
51单片机与蓝牙模块连接
0个评论
51单片机的硬件结构
0个评论
基于51单片机的无线遥控器制作
0个评论
51单片机 AD转换
0个评论
51单片机数码管递增显示
0个评论
如何实现对单片机寄存器的访问
0个评论
基于51单片机的指纹密码锁
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
51单片机
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#include <INTRINS.H> //包含延时头文件
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_();_nop_();
sbit AD=P1^0; //定义音频输入接口
sbit K1=P1^2; //定义功能按键接口
sbit K2=P1^4; //定义功能按键接口
sbit K3=P1^5; //定义功能按键接口
sbit K4=P1^7; //定义功能按键接口
sbit K5=P3^6; //定义功能按键接口
sbit K6=P3^5; //定义功能按键接口
sbit K7=P3^2; //定义功能按键接口
sbit K8=P3^4; //定义功能按键接口
sbit L1=P0^3; sbit L2=P4^5; sbit L3=P2^4; sbit L4=P2^2; sbit H1=P0^5;
sbit L5=P0^1; sbit L6=P4^6; sbit L7=P2^7; sbit L8=P2^0; sbit H2=P0^6;
sbit L9=P0^0; sbit L10=P0^7; sbit L11=P2^6; sbit L12=P1^6; sbit H3=P4^4;
sbit L13=P1^3; sbit L14=P0^4; sbit L15=P2^5; sbit L16=P3^3; sbit H4=P2^3;
sbit H5=P4^7;
//定义光立方的接口全部高电平有效
sbit LED1=P0^2; sbit LED2=P2^1;
sbit LED3=P3^7; sbit LED4=P1^1;
//定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效
unsigned char bdata dzzc0;
sbit dzzc07=dzzc0^7;
sbit dzzc06=dzzc0^6;
sbit dzzc05=dzzc0^5;
sbit dzzc04=dzzc0^4;
sbit dzzc03=dzzc0^3;
sbit dzzc02=dzzc0^2;
sbit dzzc01=dzzc0^1;
sbit dzzc00=dzzc0^0;
unsigned char bdata dzzc1;
sbit dzzc17=dzzc1^7;
sbit dzzc16=dzzc1^6;
sbit dzzc15=dzzc1^5;
sbit dzzc14=dzzc1^4;
sbit dzzc13=dzzc1^3;
sbit dzzc12=dzzc1^2;
sbit dzzc11=dzzc1^1;
sbit dzzc10=dzzc1^0;
unsigned char bdata dzzc2;
sbit dzzc27=dzzc2^7;
sbit dzzc26=dzzc2^6;
sbit dzzc25=dzzc2^5;
sbit dzzc24=dzzc2^4;
sbit dzzc23=dzzc2^3;
sbit dzzc22=dzzc2^2;
sbit dzzc21=dzzc2^1;
sbit dzzc20=dzzc2^0;
unsigned char bdata dzzc3;
sbit dzzc37=dzzc3^7;
sbit dzzc36=dzzc3^6;
sbit dzzc35=dzzc3^5;
sbit dzzc34=dzzc3^4;
sbit dzzc33=dzzc3^3;
sbit dzzc32=dzzc3^2;
sbit dzzc31=dzzc3^1;
sbit dzzc30=dzzc3^0;
//调整数字显示的数据用分别为变的1234
// 4 dzzc6
//3 2 dzzc7 dzzc5
// 1 dzzc4
unsigned char bdata dzzc4;
sbit dzzc47=dzzc4^7;
sbit dzzc46=dzzc4^6;
sbit dzzc45=dzzc4^5;
sbit dzzc44=dzzc4^4;
sbit dzzc43=dzzc4^3;
sbit dzzc42=dzzc4^2;
sbit dzzc41=dzzc4^1;
sbit dzzc40=dzzc4^0;
unsigned char bdata dzzc5;
sbit dzzc57=dzzc5^7;
sbit dzzc56=dzzc5^6;
sbit dzzc55=dzzc5^5;
sbit dzzc54=dzzc5^4;
sbit dzzc53=dzzc5^3;
sbit dzzc52=dzzc5^2;
sbit dzzc51=dzzc5^1;
sbit dzzc50=dzzc5^0;
unsigned char bdata dzzc6;
sbit dzzc67=dzzc6^7;
sbit dzzc66=dzzc6^6;
sbit dzzc65=dzzc6^5;
sbit dzzc64=dzzc6^4;
sbit dzzc63=dzzc6^3;
sbit dzzc62=dzzc6^2;
sbit dzzc61=dzzc6^1;
sbit dzzc60=dzzc6^0;
unsigned char bdata dzzc7;
sbit dzzc77=dzzc7^7;
sbit dzzc76=dzzc7^6;
sbit dzzc75=dzzc7^5;
sbit dzzc74=dzzc7^4;
sbit dzzc73=dzzc7^3;
sbit dzzc72=dzzc7^2;
sbit dzzc71=dzzc7^1;
sbit dzzc70=dzzc7^0;
unsigned int CYCLE=100,PWM_LOW=1110,shan=0,saom=0,shuzi1,shuzi2=0,shuzi3=0,shuzi4=0;//定义周期并赋值
unsigned char YL1=0,YL2=0,YL3=0,YL4=0,YL5=0,YL6=0,YL7=0,YL8=0,YL9=0,YL10=0,YL11=0,YL12=0,YL13=0,YL14=0,YL15=0,YL16=0;//高度值
unsigned char lie=0,hang=0,ceng=0,keyy,keyc,keyx;
unsigned int donghua=0,nehx;
unsigned char yinyue4X4[]= //定义4X4X4整个屏幕的显示数据,高电平有效,没有音乐的时候默认不亮
{
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
};
unsigned char code shuzu4X4[]= //定义4X4X4整个屏幕的显示数据,根据取字模软件进行提取高电平有效
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//0帧
0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//1帧
0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//2帧
0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//3帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//4帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//5帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//6帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//7帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//8帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//9帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//10帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//11帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//12帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,//13帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,//14帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,//15帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//16帧
0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//17帧
0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//18帧
0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//19帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//20帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//21帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//22帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//23帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//24帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,//25帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,//26帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,//27帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,//28帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,//29帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,//30帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,//31帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,//32帧
};
void Delay(unsigned int t)
{ unsigned char a;
for(a=t;a>0;a--);
_nop_(); //if Keil,require use intrins.h
}
void init()
{
P4SW=0xff; //定义P4口为I/O口
P0M1=0x00; //I/O口0模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
P0M0=0xff; //定义P0为强上拉输出.
P1M1=0x01;
P1M0=0x4a; //定义P1为强上拉输出. P.14作为AD此时不能作为强上蜡
P2M1=0x00;
P2M0=0xff; //定义P2为强上拉输出.
P3M1=0x00;
P3M0=0x88; //定义P3为强上拉输出.
P4M1=0x00;
P4M0=0xff; //定义P4为强上拉输出.
}
void hansao(unsigned char hs,unsigned char shangxia)
{
if(shangxia==0)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //作为控制显示高度的时候调用
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
}
}
else if(shangxia==1)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //平时的时候调用这个显示其他图形和变化
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
}
}
}
void KEYSCAN(void)
{
if(K1==0&&K2==0&&K3==0&&K4==0&&K5==0){keyy=0;} //00000 0 //全灭
else if(K1==0&&K2==0&&K3==0&&K4==0&&K5==1){keyy=1;} //00001 1
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==0){keyy=2;} //00010 2
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==1){keyy=3;} //00011 3
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==0){keyy=4;} //00100 4
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==1){keyy=5;} //00101 5
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==0){keyy=6;} //00110 6
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==1){keyy=7;} //00111 7
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==0){keyy=8;} //01000 8
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==1){keyy=9;} //01001 9
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==0){keyy=10;} //01010 10
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==1){keyy=11;} //01011 11
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==0){keyy=12;} //01100 12
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==1){keyy=13;} //01101 13
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==0){keyy=14;} //01110 14
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==1){keyy=15;} //01111 15
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==0){keyy=16;} //10000 16
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==1){keyy=17;} //10001 17
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==0){keyy=18;} //10010 18
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==1){keyy=19;} //10011 19
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==0){keyy=20;} //10100 20
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==1){keyy=21;} //10101 21
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==0){keyy=22;} //10110 22
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==1){keyy=23;} //10111 23
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==0){keyy=24;} //11000 24
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==1){keyy=25;} //11001 25
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==0){keyy=26;} //11010 26
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==1){keyy=27;} //11011 27
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==0){keyy=28;} //11100 28
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==1){keyy=29;} //11101 29
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==0){keyy=30;} //11110 30
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==1){keyy=31;} //11111 31
else if(K6==0&&K7==0&&K8==0){keyc=128;} //000 0 //30分钟
else if(K6==0&&K7==0&&K8==1){keyc=64;} //001 1
else if(K6==0&&K7==1&&K8==0){keyc=32;} //010 2
else if(K6==0&&K7==1&&K8==1){keyc=16;} //011 3
else if(K6==1&&K7==0&&K8==0){keyc=8;} //100 4
else if(K6==1&&K7==0&&K8==1){keyc=4;} //101 5
else if(K6==1&&K7==1&&K8==0){keyc=2;} //110 6
else if(K6==1&&K7==1&&K8==1){keyc=1;} //111 7
}
void disp1(void)
{
for(CYCLE=0;CYCLE<1000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
void disp(unsigned char sj)
{
for(shuzi1=0;shuzi1<sj;shuzi1++)
{
for(nehx=0;nehx<14;nehx++) //14
{
for(CYCLE=0;CYCLE<6000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
}
}
void main()
{
init(); //初始化IO口为强上蜡输出状态
LED1=0; LED2=0;
LED3=0; LED4=0; //测试底部4个LED关闭
K1=1;
K2=1;
K3=1;
K4=1;
K5=1;
K6=1;
K7=1;
K8=1;
while (1)
{
KEYSCAN();
if(keyy==0)
{keyx=keyy;
while(1){
donghua=keyy;
disp1();
KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==1)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==2)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==3)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==4)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==5)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==6)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==7)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==8)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==9)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==10)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==11)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==12)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==13)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==14)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==15)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==16)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==17)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==18)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==19)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==20)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==21)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==22)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==23)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==24)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==25)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==26)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==27)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==28)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==29)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==30)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==31)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
}
}
上面的代码和下面的能不能整合到一起啊
#include <reg51.h>
#include <intrins.h>
unsigned char key_s, key_v, tmp,tmp2,tmp3;
void send_str();
void delayms(unsigned int ms);
void send_char(unsigned char txd);
main()
{
TMOD = 0x20; // 定时器1工作于8位自动重载模式, 用于产生波特率
TH1 = 0xFD; // 波特率9600
TL1 = 0xFD;
SCON = 0x50; // 设定串行口工作方式
PCON &= 0xef; // 波特率不倍增
TR1 = 1; // 启动定时器1
IE = 0x0; // 禁止任何中断
while(1)
{
if(RI) // 是否有数据到来
{
RI = 0;
tmp = SBUF;
if (tmp==224){
send_str(); //将四个p口发给串口
} else {
if (tmp==225 || tmp==226 || tmp==227 || tmp==228 )
{
tmp2=tmp;
} else {
if (tmp2==225){
P0=tmp;
//send_str();
}
if (tmp2==226){
P1=tmp;
// send_str();
}
if ( tmp2==227){
P2=tmp;
// send_str();
}
if (tmp2==228){
P3=tmp;
}
}
}
}
delayms(25000);//延时1毫秒
}
}
void send_str()
// 传送字串
{
SBUF =224;
while(!TI);
TI = 0;
tmp3=P0;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P1;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P2;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P3;
SBUF = tmp3;
while(!TI);
TI = 0;
SBUF = 225;
while(!TI);
TI = 0;
}
void delayms(unsigned int i)//汇编后是DJNZ指令用2微秒 (双机器周期) 参数在65535以下
{
i=i/2;
while(--i);
}
以上两盒源码怎么整合到一起
#include <intrins.h>
unsigned char key_s, key_v, tmp,tmp2,tmp3;
void send_str();
void delayms(unsigned int ms);
void send_char(unsigned char txd);
main()
{
TMOD = 0x20; // 定时器1工作于8位自动重载模式, 用于产生波特率
TH1 = 0xFD; // 波特率9600
TL1 = 0xFD;
SCON = 0x50; // 设定串行口工作方式
PCON &= 0xef; // 波特率不倍增
TR1 = 1; // 启动定时器1
IE = 0x0; // 禁止任何中断
while(1)
{
if(RI) // 是否有数据到来
{
RI = 0;
tmp = SBUF;
if (tmp==224){
send_str(); //将四个p口发给串口
} else {
if (tmp==225 || tmp==226 || tmp==227 || tmp==228 )
{
tmp2=tmp;
} else {
if (tmp2==225){
P0=tmp;
//send_str();
}
if (tmp2==226){
P1=tmp;
// send_str();
}
if ( tmp2==227){
P2=tmp;
// send_str();
}
if (tmp2==228){
P3=tmp;
}
}
}
}
delayms(25000);//延时1毫秒
}
}
void send_str()
// 传送字串
{
SBUF =224;
while(!TI);
TI = 0;
tmp3=P0;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P1;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P2;
SBUF = tmp3;
while(!TI);
TI = 0;
tmp3=P3;
SBUF = tmp3;
while(!TI);
TI = 0;
SBUF = 225;
while(!TI);
TI = 0;
}
void delayms(unsigned int i)//汇编后是DJNZ指令用2微秒 (双机器周期) 参数在65535以下
{
i=i/2;
while(--i);
}
这个代码和下面的代码,可以整合到一起吗?
#include "STC12C5A.H"
#include <INTRINS.H> //包含延时头文件
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_();_nop_();
sbit AD=P1^0; //定义音频输入接口
sbit K1=P1^2; //定义功能按键接口
sbit K2=P1^4; //定义功能按键接口
sbit K3=P1^5; //定义功能按键接口
sbit K4=P1^7; //定义功能按键接口
sbit K5=P3^6; //定义功能按键接口
sbit K6=P3^5; //定义功能按键接口
sbit K7=P3^2; //定义功能按键接口
sbit K8=P3^4; //定义功能按键接口
sbit L1=P0^3; sbit L2=P4^5; sbit L3=P2^4; sbit L4=P2^2; sbit H1=P0^5;
sbit L5=P0^1; sbit L6=P4^6; sbit L7=P2^7; sbit L8=P2^0; sbit H2=P0^6;
sbit L9=P0^0; sbit L10=P0^7; sbit L11=P2^6; sbit L12=P1^6; sbit H3=P4^4;
sbit L13=P1^3; sbit L14=P0^4; sbit L15=P2^5; sbit L16=P3^3; sbit H4=P2^3;
sbit H5=P4^7;
//定义光立方的接口全部高电平有效
sbit LED1=P0^2; sbit LED2=P2^1;
sbit LED3=P3^7; sbit LED4=P1^1;
//定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效
unsigned char bdata dzzc0;
sbit dzzc07=dzzc0^7;
sbit dzzc06=dzzc0^6;
sbit dzzc05=dzzc0^5;
sbit dzzc04=dzzc0^4;
sbit dzzc03=dzzc0^3;
sbit dzzc02=dzzc0^2;
sbit dzzc01=dzzc0^1;
sbit dzzc00=dzzc0^0;
unsigned char bdata dzzc1;
sbit dzzc17=dzzc1^7;
sbit dzzc16=dzzc1^6;
sbit dzzc15=dzzc1^5;
sbit dzzc14=dzzc1^4;
sbit dzzc13=dzzc1^3;
sbit dzzc12=dzzc1^2;
sbit dzzc11=dzzc1^1;
sbit dzzc10=dzzc1^0;
unsigned char bdata dzzc2;
sbit dzzc27=dzzc2^7;
sbit dzzc26=dzzc2^6;
sbit dzzc25=dzzc2^5;
sbit dzzc24=dzzc2^4;
sbit dzzc23=dzzc2^3;
sbit dzzc22=dzzc2^2;
sbit dzzc21=dzzc2^1;
sbit dzzc20=dzzc2^0;
unsigned char bdata dzzc3;
sbit dzzc37=dzzc3^7;
sbit dzzc36=dzzc3^6;
sbit dzzc35=dzzc3^5;
sbit dzzc34=dzzc3^4;
sbit dzzc33=dzzc3^3;
sbit dzzc32=dzzc3^2;
sbit dzzc31=dzzc3^1;
sbit dzzc30=dzzc3^0;
//调整数字显示的数据用分别为变的1234
// 4 dzzc6
//3 2 dzzc7 dzzc5
// 1 dzzc4
unsigned char bdata dzzc4;
sbit dzzc47=dzzc4^7;
sbit dzzc46=dzzc4^6;
sbit dzzc45=dzzc4^5;
sbit dzzc44=dzzc4^4;
sbit dzzc43=dzzc4^3;
sbit dzzc42=dzzc4^2;
sbit dzzc41=dzzc4^1;
sbit dzzc40=dzzc4^0;
unsigned char bdata dzzc5;
sbit dzzc57=dzzc5^7;
sbit dzzc56=dzzc5^6;
sbit dzzc55=dzzc5^5;
sbit dzzc54=dzzc5^4;
sbit dzzc53=dzzc5^3;
sbit dzzc52=dzzc5^2;
sbit dzzc51=dzzc5^1;
sbit dzzc50=dzzc5^0;
unsigned char bdata dzzc6;
sbit dzzc67=dzzc6^7;
sbit dzzc66=dzzc6^6;
sbit dzzc65=dzzc6^5;
sbit dzzc64=dzzc6^4;
sbit dzzc63=dzzc6^3;
sbit dzzc62=dzzc6^2;
sbit dzzc61=dzzc6^1;
sbit dzzc60=dzzc6^0;
unsigned char bdata dzzc7;
sbit dzzc77=dzzc7^7;
sbit dzzc76=dzzc7^6;
sbit dzzc75=dzzc7^5;
sbit dzzc74=dzzc7^4;
sbit dzzc73=dzzc7^3;
sbit dzzc72=dzzc7^2;
sbit dzzc71=dzzc7^1;
sbit dzzc70=dzzc7^0;
unsigned int CYCLE=100,PWM_LOW=1110,shan=0,saom=0,shuzi1,shuzi2=0,shuzi3=0,shuzi4=0;//定义周期并赋值
unsigned char YL1=0,YL2=0,YL3=0,YL4=0,YL5=0,YL6=0,YL7=0,YL8=0,YL9=0,YL10=0,YL11=0,YL12=0,YL13=0,YL14=0,YL15=0,YL16=0;//高度值
unsigned char lie=0,hang=0,ceng=0,keyy,keyc,keyx;
unsigned int donghua=0,nehx;
unsigned char yinyue4X4[]= //定义4X4X4整个屏幕的显示数据,高电平有效,没有音乐的时候默认不亮
{
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,
};
unsigned char code shuzu4X4[]= //定义4X4X4整个屏幕的显示数据,根据取字模软件进行提取高电平有效
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//0帧
0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//1帧
0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//2帧
0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//3帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//4帧
0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//5帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//6帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//7帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//8帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//9帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//10帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//11帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//12帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X8F,0X00,0X00,0X00,//13帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XCF,0X00,0X00,0X00,//14帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XEF,0X00,0X00,0X00,//15帧
0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//16帧
0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//17帧
0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//18帧
0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//19帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//20帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//21帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//22帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//23帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,//24帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,0X00,0XFF,0X00,0X00,0X00,//25帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,0X00,0XFF,0X00,0X00,0X00,//26帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,0X00,0XFF,0X00,0X00,0X00,//27帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X00,//28帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0X8F,//29帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XCF,//30帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XEF,//31帧
0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,0X00,0XFF,0X00,0X00,0XFF,//32帧
};
void Delay(unsigned int t)
{ unsigned char a;
for(a=t;a>0;a--);
_nop_(); //if Keil,require use intrins.h
}
void init()
{
P4SW=0xff; //定义P4口为I/O口
P0M1=0x00; //I/O口0模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
P0M0=0xff; //定义P0为强上拉输出.
P1M1=0x01;
P1M0=0x4a; //定义P1为强上拉输出. P.14作为AD此时不能作为强上蜡
P2M1=0x00;
P2M0=0xff; //定义P2为强上拉输出.
P3M1=0x00;
P3M0=0x88; //定义P3为强上拉输出.
P4M1=0x00;
P4M0=0xff; //定义P4为强上拉输出.
}
void hansao(unsigned char hs,unsigned char shangxia)
{
if(shangxia==0)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //作为控制显示高度的时候调用
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
}
}
else if(shangxia==1)
{
if(hs<5) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
{
if(hs==0) //选通第1行 //平时的时候调用这个显示其他图形和变化
{
H1=0;H2=1;H3=1;H4=1;H5=1; return;
}
if(hs==1) //选通第2行
{
H1=1;H2=0;H3=1;H4=1;H5=1; return;
}
if(hs==2) //选通第3行
{
H1=1;H2=1;H3=0;H4=1;H5=1; return;
}
if(hs==3) //选通第4行
{
H1=1;H2=1;H3=1;H4=0;H5=1; return;
}
if(hs==4) //选通第5行
{
H1=1;H2=1;H3=1;H4=1;H5=0; return;
}
}
}
}
void KEYSCAN(void)
{
if(K1==0&&K2==0&&K3==0&&K4==0&&K5==0){keyy=0;} //00000 0 //全灭
else if(K1==0&&K2==0&&K3==0&&K4==0&&K5==1){keyy=1;} //00001 1
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==0){keyy=2;} //00010 2
else if(K1==0&&K2==0&&K3==0&&K4==1&&K5==1){keyy=3;} //00011 3
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==0){keyy=4;} //00100 4
else if(K1==0&&K2==0&&K3==1&&K4==0&&K5==1){keyy=5;} //00101 5
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==0){keyy=6;} //00110 6
else if(K1==0&&K2==0&&K3==1&&K4==1&&K5==1){keyy=7;} //00111 7
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==0){keyy=8;} //01000 8
else if(K1==0&&K2==1&&K3==0&&K4==0&&K5==1){keyy=9;} //01001 9
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==0){keyy=10;} //01010 10
else if(K1==0&&K2==1&&K3==0&&K4==1&&K5==1){keyy=11;} //01011 11
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==0){keyy=12;} //01100 12
else if(K1==0&&K2==1&&K3==1&&K4==0&&K5==1){keyy=13;} //01101 13
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==0){keyy=14;} //01110 14
else if(K1==0&&K2==1&&K3==1&&K4==1&&K5==1){keyy=15;} //01111 15
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==0){keyy=16;} //10000 16
else if(K1==1&&K2==0&&K3==0&&K4==0&&K5==1){keyy=17;} //10001 17
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==0){keyy=18;} //10010 18
else if(K1==1&&K2==0&&K3==0&&K4==1&&K5==1){keyy=19;} //10011 19
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==0){keyy=20;} //10100 20
else if(K1==1&&K2==0&&K3==1&&K4==0&&K5==1){keyy=21;} //10101 21
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==0){keyy=22;} //10110 22
else if(K1==1&&K2==0&&K3==1&&K4==1&&K5==1){keyy=23;} //10111 23
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==0){keyy=24;} //11000 24
else if(K1==1&&K2==1&&K3==0&&K4==0&&K5==1){keyy=25;} //11001 25
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==0){keyy=26;} //11010 26
else if(K1==1&&K2==1&&K3==0&&K4==1&&K5==1){keyy=27;} //11011 27
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==0){keyy=28;} //11100 28
else if(K1==1&&K2==1&&K3==1&&K4==0&&K5==1){keyy=29;} //11101 29
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==0){keyy=30;} //11110 30
else if(K1==1&&K2==1&&K3==1&&K4==1&&K5==1){keyy=31;} //11111 31
else if(K6==0&&K7==0&&K8==0){keyc=128;} //000 0 //30分钟
else if(K6==0&&K7==0&&K8==1){keyc=64;} //001 1
else if(K6==0&&K7==1&&K8==0){keyc=32;} //010 2
else if(K6==0&&K7==1&&K8==1){keyc=16;} //011 3
else if(K6==1&&K7==0&&K8==0){keyc=8;} //100 4
else if(K6==1&&K7==0&&K8==1){keyc=4;} //101 5
else if(K6==1&&K7==1&&K8==0){keyc=2;} //110 6
else if(K6==1&&K7==1&&K8==1){keyc=1;} //111 7
}
void disp1(void)
{
for(CYCLE=0;CYCLE<1000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
void disp(unsigned char sj)
{
for(shuzi1=0;shuzi1<sj;shuzi1++)
{
for(nehx=0;nehx<14;nehx++) //14
{
for(CYCLE=0;CYCLE<6000;CYCLE++) //1s
{
for(saom=0;saom<5;saom++)
{
dzzc0=shuzu4X4[saom+donghua*20]; //将第一个需要分配的数据赋值个为变量进行分配给L1-L4
L1=dzzc07;L2=dzzc06;L3=dzzc05;L4=dzzc04;
dzzc1=shuzu4X4[saom+donghua*20+5]; //将第一个需要分配的数据赋值个为变量进行分配给L5-L8
L5=dzzc17;L6=dzzc16;L7=dzzc15;L8=dzzc14;
dzzc2=shuzu4X4[saom+donghua*20+10]; //将第一个需要分配的数据赋值个为变量进行分配给L9-L12
L9=dzzc27;L10=dzzc26;L11=dzzc25;L12=dzzc24;
dzzc3=shuzu4X4[saom+donghua*20+15]; //将第一个需要分配的数据赋值个为变量进行分配给L13-L16
L13=dzzc37;L14=dzzc36;L15=dzzc35;L16=dzzc34;
hansao(saom,0);
Delay(10);
H1=1;H2=1;H3=1;H4=1;H5=1;
}
}
}
}
}
void main()
{
init(); //初始化IO口为强上蜡输出状态
LED1=0; LED2=0;
LED3=0; LED4=0; //测试底部4个LED关闭
K1=1;
K2=1;
K3=1;
K4=1;
K5=1;
K6=1;
K7=1;
K8=1;
while (1)
{
KEYSCAN();
if(keyy==0)
{keyx=keyy;
while(1){
donghua=keyy;
disp1();
KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==1)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==2)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==3)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==4)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==5)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==6)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==7)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==8)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==9)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==10)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==11)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==12)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==13)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==14)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==15)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==16)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==17)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==18)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==19)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==20)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==21)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==22)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==23)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==24)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==25)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==26)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==27)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==28)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==29)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==30)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
else if(keyy==31)
{keyx=keyy;
donghua=keyy;
disp(keyc);
while(1){
donghua=0;disp1();KEYSCAN();
if(keyx!=keyy){break;}}
}
}
}
一周热门 更多>