欢迎来到天天文库
浏览记录
ID:61444834
大小:26.50 KB
页数:8页
时间:2021-01-31
《单片机C语言程序.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、1流水#includesbitP1_0=P1^0;sbitP1_1=P1^1;sbitP1_2=P1^2;sbitP1_3=P1^3;sbitP1_7=P1^7;unsignedcharID;voiddelayms(unsignedchari){unsignedcharj;for(i;i>0;i--)for(j=1000;j>0;j--);}voidmain(void){while(1){if(P1_7==0){delayms(100);if(P1_7==0){ID++;if(ID==4){ID=0;}while(P
2、1_7==0);}}switch(ID){case0:P1_0=~P1_0;P1_1=1;P1_2=1;P1_3=1;delayms(100);break;case1:P1_1=~P1_1;P1_0=1;P1_2=1;P1_3=1;delayms(100);break;case2:P1_2=~P1_2;P1_0=1;P1_1=1;P1_3=1;delayms(100);break;case3:P1_3=~P1_3;P1_0=1;P1_1=1;P1_2=1;delayms(100);break;}}}2抢答器#include3、.h>#include#definecs273XBYTE[0xCFA0]sbitRST=P1^7;sbitK1=P1^0;sbitK2=P1^1;sbitK3=P1^2;sbitP1_3=P1^3;unsignedcharcodetable[4]={0x06,0x5b,0x4f,0x00};voiddelay(unsignedk){unsignedinti,j;for(i=0;i4、y(30);if(K1==0){cs273=table[0];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K2==0){delay(30);if(K2==0){cs273=table[1];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K3==0){delay(30);if(K3==0){cs273=table[2];while(1)if(RST==0){cs273=table[3];gotostart;}}}5、}}3五人表决器#includesbitRST=P1^7;sbitK1=P1^0;sbitK2=P1^1;sbitK3=P1^2;sbitK4=P1^3;sbitK5=P1^4;sbitP1_6=P1^6;unsignedcharcount,a,b,c,d,e;voiddelay(unsignedk){unsignedinti,j;for(i=0;i6、a=1;}}elseif(K2==0){delay(30);if(K2==0){while(K2==0);b=1;}}elseif(K3==0){delay(30);if(K3==0){while(K3==0);c=1;}}elseif(K4==0){delay(30);if(K4==0){while(K4==0);d=1;}}elseif(K5==0){delay(30);if(K5==0){while(K5==0);e=1;}}count=a+b+c+d+e;if(count>=3){P1_6=0;delay(200);}if(R7、ST==0){delay(30);if(RST==0){a=0,b=0,c=0,d=0,e=0,count=0;P1_6=1;}}}}4串口#include#include#defineucharunsignedcharucharcodeTable[18]={1,3,7,0x0f,0x1F,0x3F,0x7F,0xff,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0,0xFF,00};voidDelay(unsignedinttime);voidmain(){unsign8、edinti,a;TMOD=0x20;TL1=0xF4;TH1=0xF4;TR1=1;PCON=0x00;SCON=0x50;while(1){for(i=0;i<18;i++){SBUF=Table[i];while(
3、.h>#include#definecs273XBYTE[0xCFA0]sbitRST=P1^7;sbitK1=P1^0;sbitK2=P1^1;sbitK3=P1^2;sbitP1_3=P1^3;unsignedcharcodetable[4]={0x06,0x5b,0x4f,0x00};voiddelay(unsignedk){unsignedinti,j;for(i=0;i4、y(30);if(K1==0){cs273=table[0];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K2==0){delay(30);if(K2==0){cs273=table[1];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K3==0){delay(30);if(K3==0){cs273=table[2];while(1)if(RST==0){cs273=table[3];gotostart;}}}5、}}3五人表决器#includesbitRST=P1^7;sbitK1=P1^0;sbitK2=P1^1;sbitK3=P1^2;sbitK4=P1^3;sbitK5=P1^4;sbitP1_6=P1^6;unsignedcharcount,a,b,c,d,e;voiddelay(unsignedk){unsignedinti,j;for(i=0;i6、a=1;}}elseif(K2==0){delay(30);if(K2==0){while(K2==0);b=1;}}elseif(K3==0){delay(30);if(K3==0){while(K3==0);c=1;}}elseif(K4==0){delay(30);if(K4==0){while(K4==0);d=1;}}elseif(K5==0){delay(30);if(K5==0){while(K5==0);e=1;}}count=a+b+c+d+e;if(count>=3){P1_6=0;delay(200);}if(R7、ST==0){delay(30);if(RST==0){a=0,b=0,c=0,d=0,e=0,count=0;P1_6=1;}}}}4串口#include#include#defineucharunsignedcharucharcodeTable[18]={1,3,7,0x0f,0x1F,0x3F,0x7F,0xff,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0,0xFF,00};voidDelay(unsignedinttime);voidmain(){unsign8、edinti,a;TMOD=0x20;TL1=0xF4;TH1=0xF4;TR1=1;PCON=0x00;SCON=0x50;while(1){for(i=0;i<18;i++){SBUF=Table[i];while(
4、y(30);if(K1==0){cs273=table[0];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K2==0){delay(30);if(K2==0){cs273=table[1];while(1)if(RST==0){cs273=table[3];gotostart;}}}elseif(K3==0){delay(30);if(K3==0){cs273=table[2];while(1)if(RST==0){cs273=table[3];gotostart;}}}
5、}}3五人表决器#includesbitRST=P1^7;sbitK1=P1^0;sbitK2=P1^1;sbitK3=P1^2;sbitK4=P1^3;sbitK5=P1^4;sbitP1_6=P1^6;unsignedcharcount,a,b,c,d,e;voiddelay(unsignedk){unsignedinti,j;for(i=0;i6、a=1;}}elseif(K2==0){delay(30);if(K2==0){while(K2==0);b=1;}}elseif(K3==0){delay(30);if(K3==0){while(K3==0);c=1;}}elseif(K4==0){delay(30);if(K4==0){while(K4==0);d=1;}}elseif(K5==0){delay(30);if(K5==0){while(K5==0);e=1;}}count=a+b+c+d+e;if(count>=3){P1_6=0;delay(200);}if(R7、ST==0){delay(30);if(RST==0){a=0,b=0,c=0,d=0,e=0,count=0;P1_6=1;}}}}4串口#include#include#defineucharunsignedcharucharcodeTable[18]={1,3,7,0x0f,0x1F,0x3F,0x7F,0xff,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0,0xFF,00};voidDelay(unsignedinttime);voidmain(){unsign8、edinti,a;TMOD=0x20;TL1=0xF4;TH1=0xF4;TR1=1;PCON=0x00;SCON=0x50;while(1){for(i=0;i<18;i++){SBUF=Table[i];while(
6、a=1;}}elseif(K2==0){delay(30);if(K2==0){while(K2==0);b=1;}}elseif(K3==0){delay(30);if(K3==0){while(K3==0);c=1;}}elseif(K4==0){delay(30);if(K4==0){while(K4==0);d=1;}}elseif(K5==0){delay(30);if(K5==0){while(K5==0);e=1;}}count=a+b+c+d+e;if(count>=3){P1_6=0;delay(200);}if(R
7、ST==0){delay(30);if(RST==0){a=0,b=0,c=0,d=0,e=0,count=0;P1_6=1;}}}}4串口#include#include#defineucharunsignedcharucharcodeTable[18]={1,3,7,0x0f,0x1F,0x3F,0x7F,0xff,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0,0xFF,00};voidDelay(unsignedinttime);voidmain(){unsign
8、edinti,a;TMOD=0x20;TL1=0xF4;TH1=0xF4;TR1=1;PCON=0x00;SCON=0x50;while(1){for(i=0;i<18;i++){SBUF=Table[i];while(
此文档下载收益归作者所有