资源描述:
《第七届蓝桥杯大赛模拟题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、main.c#include#include#include"head.h"#defineucharunsignedchar#defineuintunsignedint#defineulongunsignedlongsbitLSA=P1^0;sbitLSB=P1^1;sbitLSC=P1^2;sbitL1=P1^3;uinti,j,k,t,s,cs;ucharKeyValue;ucharcodeDATA[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0
2、x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};uintcodets[]={1,5,30,60};ucharcodejump[]={0x40,0x00};uchardisplaydata[8];uintTempdata[10]={0,0,0,0,0,0,0,0,0,0};voidKeyDown();voidmain(){floattp;TMOD=0x10;TH1=(65536-50000)/256;TL1=(65536-50000)%256;EA=1;ET1=1;TR1=0;L1=0;Ds18b20Re
3、adTemp();one:i=0;j=0;t=1;T1:displaydata[0]=0x00;displaydata[1]=0x00;displaydata[2]=0x00;displaydata[3]=0x00;displaydata[4]=0x00;displaydata[5]=0x40;displaydata[6]=DATA[ts[j]/10];displaydata[7]=DATA[ts[j]%10];t=ts[j];while(1){TR1=1;for(i=0;i<8;i++){switch(i){case(0):LSC=
4、0;LSB=0;LSA=0;break;case(1):LSC=0;LSB=0;LSA=1;break;case(2):LSC=0;LSB=1;LSA=0;break;case(3):LSC=0;LSB=1;LSA=1;break;case(4):LSC=1;LSB=0;LSA=0;break;case(5):LSC=1;LSB=0;LSA=1;break;case(6):LSC=1;LSB=1;LSA=0;break;case(7):LSC=1;LSB=1;LSA=1;break;}P0=displaydata[i];Delay1m
5、s(1);P0=0x00;}if(KeyValue==4){8KeyValue=0;j++;if(j==4)j=0;gotoT1;}if(KeyValue==5)gototwo;}two:i=0;j=0;k=0;s=0;cs=0;TR1=0;Ds1302Init();while(1){Ds1302ReadTime();displaydata[0]=DATA[Time[2]/16];displaydata[1]=DATA[Time[2]%16];displaydata[2]=jump[s];displaydata[3]=DATA[Tim
6、e[1]/16];displaydata[4]=DATA[Time[1]%16];displaydata[5]=jump[s];displaydata[6]=DATA[Time[0]/16];displaydata[7]=DATA[Time[0]%16];if(j!=displaydata[7]){j=displaydata[7];if(k==t){k=0;Tempdata[cs]=Ds18b20ReadTemp();cs++;if(cs==10)gotothree;}k++;s++;if(s==2)s=0;}for(i=0;i<8;
7、i++){switch(i){case(0):LSA=0;LSB=0;LSC=0;break;case(1):LSA=1;LSB=0;LSC=0;break;case(2):LSA=0;LSB=1;LSC=0;break;case(3):LSA=1;LSB=1;LSC=0;break;case(4):LSA=0;LSB=0;LSC=1;break;case(5):LSA=1;LSB=0;LSC=1;break;case(6):LSA=0;LSB=1;LSC=1;break;case(7):LSA=1;LSB=1;LSC=1;break
8、;}P0=displaydata[i];Delay1ms(1);P0=0x00;}}three:i=0;j=0;k=0;t=0;TR1=1;while(1){TH0=(65536-5000)/256;TL0=(65536