C51四位數(shù)碼管動態(tài)掃描讓其中一位閃爍_第1頁
C51四位數(shù)碼管動態(tài)掃描讓其中一位閃爍_第2頁
免費預覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、 6/6C51四位數(shù)碼管動態(tài)掃描讓其中一位閃爍 思路說明:將顯示程序放入定時器中斷,設定一閃爍標志位。定時時間為2MS,定時時間到則將標志位取反,同時也可以將按鍵掃描程序放入該定時器,則在視覺上可以看到要求位的閃爍。 #include0;x-) for(y=110;y0;y-); void display() if(flashflag=1 else P0=numdbuf0; P1=0 x01; delayus(20); P1=0 x00; if(flashflag=1 else P0=numdbuf1; P1=0 x02; delayus(20); P1=0 x00; if(flashflag

2、=1 else P0=numdbuf2; P1=0 x04; delayus(20); P1=0 x00; if(flashflag=1 else P0=numdbuf3; P1=0 x08; delayus(20); P1=0 x00; void keynum() uchar temp; P2=0 x0f; if(P2!=0 xf0) delayus(10); if(P2!=0 xf0) P2=0 xf7; delayus(10); temp=P2; switch(temp) case 0 xe7:flashbit=1;break; case 0 xd7:flashbit=2;break;

3、case 0 xb7:flashbit=3;break; case 0 x77:flashbit=4;break; default :P2=0 xfb; temp=P2; switch(temp) case 0 xeb:outnum=1;break; case 0 xdb:outnum=5;break; case 0 xbb:outnum=9;break; case 0 x7b:outnum=13;break; default:P2=0 xfd; temp=P2; switch(temp) case 0 xed:outnum=2;break; case 0 xdd:outnum=6;break

4、; case 0 xbd:outnum=10;break; case 0 x7d:outnum=14;break; default:P2=0 xfe; temp=P2; switch(temp) case 0 xee:outnum=3;break; case 0 xde:outnum=7;break; case 0 xbe:outnum=11;break; case 0 x7e:outnum=15;break; default:break; /* if(!key1) delayus(50); if(!key1) outnum=5; while(!key1); delayus(50); */ v

5、oid main() setint(); while(1) dbuf0=outnum/10; dbuf1=outnum%10; dbuf2=2; dbuf3=3; void timer1() interrupt 1 TH0=(65536-10000)/256; TL0=(65536-10000)%256; keynum(); display(); flashflag=flashflag; /8位數(shù)碼管動態(tài)顯示時間,可調(diào)節(jié), /調(diào)節(jié)時間時,調(diào)節(jié)的數(shù)閃爍顯示; /比較兩種閃爍的方法; /2011。3。6 #include #define uint unsigned int #define ucha

6、r unsigned char sbit tiaojie=P10; sbit jia=P11; sbit jian=P12; uchar code table=0 xc0,0 xf9,0 xa4,0 xb0,0 x99,0 x92,0 x82,0 xf8, 0 x80,0 x90,0 xbf; uchar a,b,num1,num2,flag100ms,flag1s,flagtj; uchar miao,fen,shi,flagjia,flagjian; bit flag_1s; uchar code wela8=0 x01,0 x02,0 x04,0 x08,0 x10,0 x20,0 x4

7、0,0 x80; uchar dula8=0,0,1,1,2,2,3,3; void delay(uint z); void intc(); void keyscan(); void disp(); void main() intc(); while(1) keyscan(); disp(); /= void intc() TMOD=0 x01; TH0=(65536-10000)/256; TL0=(65536-10000)%256; ET0=1; EA=1; TR0=1; void timer0() interrupt 1 TH0=(65536-10000)/256; TL0=(65536

8、-10000)%256; a+; if(a=10) flag100ms=1; if(a=100) a=0,flag1s=1,miao+;flag_1s=flag_1s; if(miao=60) miao=0,fen+; if(fen=60) fen=0,shi+; if(shi12) shi=1; /= void disp() uchar i,n; dula7=miao%10; dula6=miao/10; dula5=0 x0a; dula4=fen%10; dula3=fen/10; dula2=0 x0a; dula1=shi%10; dula0=shi/10; for(i=0;i5 else P0=tabledulai; else P0=tabledulai;break; case 2: if(i2 else P0=tabledulai; else P0=tabledulai;break; case 3: if(i=0 else P0=tabledulai; else P0=tabledulai;break; case 0: P0=tabledulai;break; P2=welai; delay(10); P0=0 xff; */ /= void delay(uint z) uint x; uchar

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論