完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
添加工程项目,在你的NEW GROP右击有个 Add file to "New Group",找到路径添加进去就可以了。同是新人,一起学习!
|
|
|
|
呵呵!是在新建工程中,然后把需要组合的程序分别添加到新建的工程里面吗?
|
|
|
|
file->addfile->路径->打开
|
|
|
|
可以那样做,但是不建议 。你可以自己新建一个文件(XXX.C),把你需要添加的小模块程序放到这个文件里,然后添加这个文件就可以了,记住要在main函数里对这些函数申明。或者你也可以再建一个文件(XXX.h),这里就是对你XXX.C文件里的函数的申明。https://bbs.elecfans.com/jishu_245903_1_1.html这个是具体步骤,感觉还是人家讲的好,呵呵。 |
|
|
|
嗯嗯 谢谢了!!!! |
|
|
|
合并?是想实现两个程序的两种不同的功能吧? 如果是的话当你学到后面的单片机多任务就应该会了。。那个才是一个程序实现多个功能。。或者你现在可以这样,把想合并的程序那些需要的部分写在现有的程序里面,声明函数,然后去调用。。
|
|
|
|
|
|
简单程序,调用函数就OK了,如果程序复杂,为了修改就包含头文件比较好。我们之前写了900多行的51程序在一个文件中,修改起来很麻烦.现在改用AVR时,都在包含头文件
|
|
|
|
嗯,确实,学习还没有学到家!现在就是通过调用的方法来实现,但是一直在改错,里面很多的错误! |
|
|
|
嗯 也只能调用函数方法来实现了,再深奥点就还得学习才能进行操作了! |
|
|
|
{:1:}{:1:}
|
|
|
|
路过了
|
|
|
|
嗯 谢谢大家的支持!我再仔细摸索一番!
|
|
|
|
搭车学习,谢谢啦~
|
|
|
|
#include "STC12C5A.H"
#include #define uint unsigned int #define uchar unsigned char #define nop() _nop_();_nop_(); ***it AD=P1^0; //定义音频输入接口 ***it K1=P1^2; //定义功能按键接口 ***it K2=P1^4; //定义功能按键接口 ***it K3=P1^5; //定义功能按键接口 ***it K4=P1^7; //定义功能按键接口 ***it K5=P3^6; //定义功能按键接口 ***it K6=P3^5; //定义功能按键接口 ***it K7=P3^2; //定义功能按键接口 ***it K8=P3^4; //定义功能按键接口 ***it L1=P0^3; ***it L2=P4^5; ***it L3=P2^4; ***it L4=P2^2; ***it H1=P0^5; ***it L5=P0^1; ***it L6=P4^6; ***it L7=P2^7; ***it L8=P2^0; ***it H2=P0^6; ***it L9=P0^0; ***it L10=P0^7; ***it L11=P2^6; ***it L12=P1^6; ***it H3=P4^4; ***it L13=P1^3; ***it L14=P0^4; ***it L15=P2^5; ***it L16=P3^3; ***it H4=P2^3; ***it H5=P4^7; //定义光立方的接口全部高电平有效 ***it LED1=P0^2; ***it LED2=P2^1; ***it LED3=P3^7; ***it LED4=P1^1; //定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效 unsigned char bdata dzzc0; ***it dzzc07=dzzc0^7; ***it dzzc06=dzzc0^6; ***it dzzc05=dzzc0^5; ***it dzzc04=dzzc0^4; ***it dzzc03=dzzc0^3; ***it dzzc02=dzzc0^2; ***it dzzc01=dzzc0^1; ***it dzzc00=dzzc0^0; unsigned char bdata dzzc1; ***it dzzc17=dzzc1^7; ***it dzzc16=dzzc1^6; ***it dzzc15=dzzc1^5; ***it dzzc14=dzzc1^4; ***it dzzc13=dzzc1^3; ***it dzzc12=dzzc1^2; ***it dzzc11=dzzc1^1; ***it dzzc10=dzzc1^0; unsigned char bdata dzzc2; ***it dzzc27=dzzc2^7; ***it dzzc26=dzzc2^6; ***it dzzc25=dzzc2^5; ***it dzzc24=dzzc2^4; ***it dzzc23=dzzc2^3; ***it dzzc22=dzzc2^2; ***it dzzc21=dzzc2^1; ***it dzzc20=dzzc2^0; unsigned char bdata dzzc3; ***it dzzc37=dzzc3^7; ***it dzzc36=dzzc3^6; ***it dzzc35=dzzc3^5; ***it dzzc34=dzzc3^4; ***it dzzc33=dzzc3^3; ***it dzzc32=dzzc3^2; ***it dzzc31=dzzc3^1; ***it dzzc30=dzzc3^0; //调整数字显示的数据用分别为变的1234 // 4 dzzc6 //3 2 dzzc7 dzzc5 // 1 dzzc4 unsigned char bdata dzzc4; ***it dzzc47=dzzc4^7; ***it dzzc46=dzzc4^6; ***it dzzc45=dzzc4^5; ***it dzzc44=dzzc4^4; ***it dzzc43=dzzc4^3; ***it dzzc42=dzzc4^2; ***it dzzc41=dzzc4^1; ***it dzzc40=dzzc4^0; unsigned char bdata dzzc5; ***it dzzc57=dzzc5^7; ***it dzzc56=dzzc5^6; ***it dzzc55=dzzc5^5; ***it dzzc54=dzzc5^4; ***it dzzc53=dzzc5^3; ***it dzzc52=dzzc5^2; ***it dzzc51=dzzc5^1; ***it dzzc50=dzzc5^0; unsigned char bdata dzzc6; ***it dzzc67=dzzc6^7; ***it dzzc66=dzzc6^6; ***it dzzc65=dzzc6^5; ***it dzzc64=dzzc6^4; ***it dzzc63=dzzc6^3; ***it dzzc62=dzzc6^2; ***it dzzc61=dzzc6^1; ***it dzzc60=dzzc6^0; unsigned char bdata dzzc7; ***it dzzc77=dzzc7^7; ***it dzzc76=dzzc7^6; ***it dzzc75=dzzc7^5; ***it dzzc74=dzzc7^4; ***it dzzc73=dzzc7^3; ***it dzzc72=dzzc7^2; ***it dzzc71=dzzc7^1; ***it 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 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 #include 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
#include 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 #define uint unsigned int #define uchar unsigned char #define nop() _nop_();_nop_(); ***it AD=P1^0; //定义音频输入接口 ***it K1=P1^2; //定义功能按键接口 ***it K2=P1^4; //定义功能按键接口 ***it K3=P1^5; //定义功能按键接口 ***it K4=P1^7; //定义功能按键接口 ***it K5=P3^6; //定义功能按键接口 ***it K6=P3^5; //定义功能按键接口 ***it K7=P3^2; //定义功能按键接口 ***it K8=P3^4; //定义功能按键接口 ***it L1=P0^3; ***it L2=P4^5; ***it L3=P2^4; ***it L4=P2^2; ***it H1=P0^5; ***it L5=P0^1; ***it L6=P4^6; ***it L7=P2^7; ***it L8=P2^0; ***it H2=P0^6; ***it L9=P0^0; ***it L10=P0^7; ***it L11=P2^6; ***it L12=P1^6; ***it H3=P4^4; ***it L13=P1^3; ***it L14=P0^4; ***it L15=P2^5; ***it L16=P3^3; ***it H4=P2^3; ***it H5=P4^7; //定义光立方的接口全部高电平有效 ***it LED1=P0^2; ***it LED2=P2^1; ***it LED3=P3^7; ***it LED4=P1^1; //定义脚底下4个受控制的LED灯-右下角高电平有效其余低电平有效 unsigned char bdata dzzc0; ***it dzzc07=dzzc0^7; ***it dzzc06=dzzc0^6; ***it dzzc05=dzzc0^5; ***it dzzc04=dzzc0^4; ***it dzzc03=dzzc0^3; ***it dzzc02=dzzc0^2; ***it dzzc01=dzzc0^1; ***it dzzc00=dzzc0^0; unsigned char bdata dzzc1; ***it dzzc17=dzzc1^7; ***it dzzc16=dzzc1^6; ***it dzzc15=dzzc1^5; ***it dzzc14=dzzc1^4; ***it dzzc13=dzzc1^3; ***it dzzc12=dzzc1^2; ***it dzzc11=dzzc1^1; ***it dzzc10=dzzc1^0; unsigned char bdata dzzc2; ***it dzzc27=dzzc2^7; ***it dzzc26=dzzc2^6; ***it dzzc25=dzzc2^5; ***it dzzc24=dzzc2^4; ***it dzzc23=dzzc2^3; ***it dzzc22=dzzc2^2; ***it dzzc21=dzzc2^1; ***it dzzc20=dzzc2^0; unsigned char bdata dzzc3; ***it dzzc37=dzzc3^7; ***it dzzc36=dzzc3^6; ***it dzzc35=dzzc3^5; ***it dzzc34=dzzc3^4; ***it dzzc33=dzzc3^3; ***it dzzc32=dzzc3^2; ***it dzzc31=dzzc3^1; ***it dzzc30=dzzc3^0; //调整数字显示的数据用分别为变的1234 // 4 dzzc6 //3 2 dzzc7 dzzc5 // 1 dzzc4 unsigned char bdata dzzc4; ***it dzzc47=dzzc4^7; ***it dzzc46=dzzc4^6; ***it dzzc45=dzzc4^5; ***it dzzc44=dzzc4^4; ***it dzzc43=dzzc4^3; ***it dzzc42=dzzc4^2; ***it dzzc41=dzzc4^1; ***it dzzc40=dzzc4^0; unsigned char bdata dzzc5; ***it dzzc57=dzzc5^7; ***it dzzc56=dzzc5^6; ***it dzzc55=dzzc5^5; ***it dzzc54=dzzc5^4; ***it dzzc53=dzzc5^3; ***it dzzc52=dzzc5^2; ***it dzzc51=dzzc5^1; ***it dzzc50=dzzc5^0; unsigned char bdata dzzc6; ***it dzzc67=dzzc6^7; ***it dzzc66=dzzc6^6; ***it dzzc65=dzzc6^5; ***it dzzc64=dzzc6^4; ***it dzzc63=dzzc6^3; ***it dzzc62=dzzc6^2; ***it dzzc61=dzzc6^1; ***it dzzc60=dzzc6^0; unsigned char bdata dzzc7; ***it dzzc77=dzzc7^7; ***it dzzc76=dzzc7^6; ***it dzzc75=dzzc7^5; ***it dzzc74=dzzc7^4; ***it dzzc73=dzzc7^3; ***it dzzc72=dzzc7^2; ***it dzzc71=dzzc7^1; ***it 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 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;}} } } } |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
飞凌嵌入式-ELFBOARD-RGB LCD屏接口的PCB设计要点
346 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-spi编程示例之spi编写程序
786 浏览 0 评论
《DNK210使用指南 -CanMV版 V1.0》第三十七章 image图像对比实验
756 浏览 0 评论
961 浏览 1 评论
652 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11674 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-13 11:54 , Processed in 0.842091 second(s), Total 70, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号