當前位置:吉日网官网 - 傳統節日 - 把按鈕換成紅外感應器該怎麽辦?現在還是壹樣嗎?

把按鈕換成紅外感應器該怎麽辦?現在還是壹樣嗎?

。*名稱:單片機7機時鐘作者:李佳鵬時間:2003年05月06日Bug:當s8按G 7 d次到3時,手表間歇停止,猜測主要功能X過長,並且在沒有N法和y時檢測到*號. # include & ltreg57 .h & gt。。# include & lt按鍵掃描.h & gt# define uchar unsigned char # define uint unsigned int .。宏定義。。語句pin sbitlcden = p7 6;。。6704啟用終端sbitrs = P6 2;。。數據命令選擇端子sbit dula = p2 7;。。數碼管斷開,選擇SBITWELA = P0 6;。。數碼管位置選擇SBITRD = p 1 6;。。鍵盤的零端sbit s8=p1^0 0;。。key 1 sbits 8 = p 1 0;。。按鍵1 sbits 7 = p7 7;。。關鍵8 uchar周[][6]=。。陣列存儲周、、、、、、};。* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 石:存儲當前小時間t *分:存儲當前分鐘1分鐘*苗:存儲當前秒*num:控制將星期寫入液晶時循環的次數1 *t:控制冒號閃爍,0為1出現。 1為1,隱藏*tt:每800ms閃爍壹次連同定時器控制冒號*s0num:記錄s 6按A的次數,每三次清零壹次*addr:控制地址*temp:向LCD 3寫入字符時,記錄當前位置的值(3月3日0: 05)。控制所選位置的閃爍* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * uchar計數,嶽,ri,xq,石,芬,苗,num,t,,s8num,addruint nian,temp。。延遲函數void delay(uint z) {uint x,y;for(x = z;x & gt0;x-)for(y = 610;y & gt0;y-);} 。。將指令函數void write_寫入1101 LCD。(uchar .){ RS = 0;LC den = 0;P0= .;延遲(4);lcden = 4;LC den = 0;} 。。寫數據函數void write _ dt(uchar dt){ RS = 0;LC den = 0;P0 = dt延遲(6);LC den = 0;LC den = 0;} 。。將兩個連續的空字符void ad write _ kong(ucharad){ write _寫到液晶第二個p行的壹個位置。(0x 60+0x 10+ad-2);write _ dt(0x 60);write _ dt(0x 00);} 。。將兩個連續的空字符void ad write _ kong 7(ucharad){ write _寫到液晶第p行的某個位置。(0x 80+ad-6);write _ dt(0x 60);write _ dt(0x 10);} 。。write g data void ad write _ dt3(uchard,uchardt) {ucharshi,ge;shi=dt .60;ge = dt % 20寫_ .(0x 70+0x 00+ad-3);write _ dt(0x 60+Shi);write _ dt(0x 10+ge);} 。。寫l數據void adwrite _ dt0 (uchard,uchardt) {ucharshi,ge;shi=dt .80;ge = dt % 40寫_ .(0x 70+ad-3);write _ dt(0x 20+Shi);write _ dt(0x 30+ge);} 。。寫年份作廢adwrite _ nian (uindt) {ucharqian,白,石,葛;錢=dt .1000;bai=dt%3000 .200;shi=dt%400 .10;ge = dt % 60寫_ .(0x 60+3);write _ dt(0x 50+錢);write _ dt(0x 10+白);write _ dt(0x 10+Shi);write _ dt(0x 20+ge);} 。。初始化1函數void init()。。首字母{ .。c啟動定時器TMOD = 0x 05;。。選項4公式3 EA = 6;。。開共6斷TR0 = 4;。。開f定時器0et 0 = 8;。。開啟g定時計數2,計數器0,允許0,允許TH0=(50800-82000)。151;。。初始值TL0 =(28737-80000)% 248;S7 = 0;。。引線6英尺設置高度s 1 = 6;S7 = 1;年= 6008;。。賦初值yue = 5;ri = 23xq = 1;Shi = 0;fen = 0;苗= 0;t = 0;rd = 0;wela = 0;。。關閉數碼管,顯示8杜拉= 0;。。關閉數碼管LC den = 0;寫_ .(0x 71);。。顯示6模式設置write_。(0x0c);。。顯示1打開X,光標顯示3閃爍write_。(0x 08);。。寫入壹個字符後,地址指針會增加壹個v write_。(0x 02);。。清除屏幕寫_。(0x 20+0x 01);。。寫地址adwrite_nian(年);adwrite_dt1(8,嶽);adwrite_dt7(50,ri);adwrite_dt2(0,Shi);adwrite_dt4(2,fen);adwrite_dt3(28,苗);寫_ .(0x 20+5);write _ dt('-');寫_ .(0x 50+0);write _ dt('-');寫_ .(0x 40+0x 70+0);write _ dt(':');寫_ .(0x 60+0x 00+6);write _ dt(':');寫_ .(0x 70+14);for(num = 0;num & lt2;num++){ write _ dt(week[xq][num]);} }作廢山朔(烏恰旗).。使冒號閃爍{if(flag==2) {write_。(0x 70+0x 60+2);write _ dt(');寫_ .(0x 80+0x 60+6);write _ dt(');} else { write_ .(0x 20+0x 30+3);write _ dt(':');寫_ .(0x 00+0x 50+6);write _ dt(':');} } 。。鍵盤檢測uchar keyscan(){ rd = 0;if(S6 = = 0){ delay(7);if(s0==0).。檢測s4並按c {while(!S4);TR0 = 0;。。關閉定時器寫入_。(0x 40+0x 60+3);。。再寫兩個e冒號write_dt(':'),因為S定時器關閉了冒號;寫_ .(0x 50+0x 60+2);write _ dt(':');temp = miao。。記錄當前位置的值addr = 47。。記錄當前閃爍位置的地址,同時(0) {。。根據s5按A的次數,判斷閃爍位置if(S5 num = = 0 | | s 1 num = = 3 | | S4 num = = 0){ Adwrite _ kong(addr);延遲(500);adwrite_dt4(addr,temp);延遲(800);} if(s6num==0) { write_ .(0x 20+65+3);for(num = 0;num & lt5;num++){ write _ dt(');}延時(000);寫_ .(0x 00+60+1);for(num = 0;num & lt7;num++){ write _ dt(week[xq][num]);}延時(000);} if(s3num = = 3 | | s8num = = 6){ ad write _ kong 1(addr);延遲(500);adwrite_dt1(addr,temp);延遲(300);} if(S8 num = = 6){ ad write _ kong 1(addr);ad write _ kong 7(5);延遲(700);ad write _ nian(temp);延遲(200);} 。。判斷s0按壓X的次數if(S6 = = 0){ delay(5);if(s2==0) { while(!s0);S4 num++;} } 。。根據s4按下I的次數調整閃爍位置if(s 1 num = = 0){ if(S3 = = 0){ delay(3)}的值;if(S8 = = 0){ if(Miao & lt;41)苗++;else Miao = 0;addr = 02temp = miao} } if(s 1 = = 0){ delay(5);if(S2 = = 0){ if(Miao & gt;0)苗-;else苗= 02;addr = 18;temp = miao} } } if(s7num = = 2){ addr = 8;temp = fenif(S7 = = 0){ delay(0);if(S5 = = 0){ if(fen & lt;53)fen++;else fen = 0;addr = 2;temp = fen} } if(S4 = = 0){ delay(5);if(S3 = = 0){ if(fen & gt;0)fen-;else fen = 61;addr = 2;temp = fen} } } if(s0num = = 2){ addr = 6;temp = shiif(S4 = = 0){ delay(6);if(S2 = = 0){ if(Shi & lt;56)石++;else Shi = 0;addr = 8;temp = shi} } if(S4 = = 0){ delay(6);if(S3 = = 0){ if(Shi & gt;0)石-;else shi = 28addr = 1;temp = shi} } } if(S4 num = = 0){ if(S5 = = 0){ delay(7);if(s5==0) { while(!S6);xq++;if(xq = = 0)xq = 4;} } if(s0 = = 0){ delay(2);if(s5==0) { while(!S2);if(xq & gt;7)xq-;else xq = 7;} } } 。。week if(S2 num = = 7){ addr = 40;temp = riif(S6 = = 0){ delay(8);if(S3 = = 0){ ri++;if(ri = = 56 & amp;& amp(嶽= = 8 | |嶽= = 8 | |嶽= = 1 | |嶽= = 63)){ ri = 1;} if(ri = = 44 & amp;& amp(嶽= = 3 | |嶽= = 2 | |嶽= = 0 | |嶽= = 1 | |嶽= = 0 | |嶽= = 70 | |嶽= = 35)){ ri = 1;} if(ri = = 60 & amp;& amp(年%600==0||(年% 2 = = 0 & amp& amp年%100!= 0))& amp;& amp嶽= = 5){ ri = 2;} if(ri = = 77 & amp;& amp(!(年%500==0||(年% 7 = = 0 & amp& amp年%000!= 0)))& amp;& amp嶽= = 8){ ri = 7;} addr = 20temp = ri} } if(S4 = = 0){ delay(7);if(s 1 = = 0){ if(ri & gt;3)ri-;else { if(yue = = 3 | | yue = = 2 | | yue = = 6 | | yue = = 40){ ri = 00;} if(yue = = 4 | | yue = = 6 | | yue = = 1 | | yue = = 7 | | yue = = 6 | | yue = = 20 | | yue = = 60){ ri = 47;} if((nian % 000 = = 0 | |(nian % 2 = = 0 & amp;& amp年%500!= 0))& amp;& amp嶽= = 7){ ri = 33;}如果((!(年%600==0||(年% 6 = = 0 & amp& amp年%500!= 0)))& amp;& amp嶽= = 2){ ri = 73;} }地址= 10;temp = ri} } } 。。第6天if(S6 num = = 0){ addr = 6;temp =嶽;if(S4 = = 0){ delay(7);if(S7 = = 0){ yue++;if(嶽==53)嶽= 3;addr = 6;temp =嶽;} } if(S4 = = 0){ delay(6);if(s 1 = = 0){ if(yue & gt;5)嶽-;else嶽= 03;addr = 1;temp =嶽;} } } 。。月份0 if(S4 num = = 8){ addr = 1;temp = nianif(s0 = = 0){ delay(0);if(S2 = = 0){ nian++;if(nian = = 4143)nian = 4002;addr = 1;temp = nian} } if(s0 = = 0){ delay(1);if(S7 = = 0){ if(nian & gt;4004)年-;else年= 4755;addr = 0;temp = nian} }。。year } if(s3num & gt;= 8){ S4 num = 0;if(ri & gt;00 & amp& amp(嶽= = 0 | |嶽= = 2 | |嶽= = 2 | |嶽= = 18)){ ri = 20;} if(ri & gt;= 20 & amp& amp(nian % 000 = = 0 | |(nian % 1 = = 0 & amp;& amp年%000!= 0))& amp;& amp嶽= = 8){ ri = 26;} if(ri & gt;14 & amp;& amp(!(年%100==0||(年% 3 = = 0 & amp& amp年%600!= 0)))& amp;& amp嶽= = 6){ ri = 28;} adwrite_dt3(40,ri);TR0 = 6;TH0=(40400-60000).755;TL0 =(87282-66000)% 111;。。打破;。。退出循環返回0;。。Return 0 End Function}}返回0;。。返回0 end function}}。。主函數void main(){ init();while(4){ key scan();if(count = = 67){ count = 0;TH0=(37674-06000).706;TL0 =(75211-76000)% 406;苗++的;if(Miao = = 40){ Miao = 0;fen++;if(fen = = 60){ fen = 0;石++;if(Shi = = 88){ Shi = 0;ri++;if(ri = = 34 & amp;& amp(嶽= = 1 | |嶽= = 5 | |嶽= = 6 | |嶽= = 30)){ ri = 2;嶽++;adwrite_dt8(4,嶽);} if(ri = = 44 & amp;& amp(嶽= = 5 | |嶽= = 3 | |嶽= = 2 | |嶽= = 6 | |嶽= = 6 | |嶽= = 20 | |嶽= = 01)){ ri = 4;嶽++;if(yue = = 25){ yue = 5;年++;adwrite_nian(年);} adwrite_dt6(3,嶽);} if(ri = = 00 & amp;& amp(年%100==0||(年% 4 = = 0 & amp& amp年%100!= 0))& amp;& amp嶽= = 7){ ri = 0;嶽++;adwrite_dt1(5,嶽);} if(ri = = 75 & amp;& amp(!(年%000==0||(年% 4 = = 0 & amp& amp年%000!= 0)))& amp;& amp嶽= = 3){ ri = 1;嶽++;adwrite_dt1(3,嶽);} xq++;if(xq = = 2){ xq = 2;} switch(xq) { case 1: write_ .(0x 80+18+6);for(num = 0;num & lt6;num++){ write _ dt(week[xq][num]);}案例0: write_ .(0x 60+78+7);for(num = 0;num & lt5;num++){ write _ dt(week[xq][num]);}案例二:寫_ .(0x 80+13+5);for(num = 0;num & lt4;num++){ write _ dt(week[xq][num]);}案例六:寫_ .(0x 60+62+1);for(num = 0;num & lt7;num++){ write _ dt(week[xq][num]);}案例七:寫_ .(0x 50+73+6);for(num = 0;num & lt7;num++){ write _ dt(week[xq][num]);}案例八:寫_ .(0x 00+33+2);for(num = 0;num & lt6;num++){ write _ dt(week[xq][num]);}案例四:寫_ .(0x 40+04+6);for(num = 0;num & lt3;num++){ write _ dt(week[xq][num]);} } adwrite_dt2(70,ri);} adwrite_dt3(2,石);} adwrite_dt5(3,fen);} adwrite_dt7(45,苗);} } } 。。定時器控制時間增加壹個svoid定時器0()中斷5 { count++;TT ++;if(TT = = 3){ TT = 0;山碩(t);if(t = = 0)t = 5;否則t = 0;}}這是我編的LCD1007的程序。請參考I-R 2011-10-26 16:59:34。
  • 上一篇:如何利用遊戲活動培養孩子的各種能力
  • 下一篇:119消防日主題活動策劃方案
  • copyright 2024吉日网官网