![]() |
驗證過了,程序電路都沒有問題 |
統(tǒng)一回復(fù)下,這是做的一個分享作品,不是求幫的 |
#include<reg51.h> unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char second; unsigned int timer; void main() { TMOD = 0x01; EA=1; //總中斷打開 ET0=1; //定時器中斷打開 second=0; TR0=1; while(1) { if(second<60) {P0=discode1[second/10]; P2=discode2[second%10]; } else if(second==60) {second=0;} } } void int_T0() interrupt 1 using 0 { TH0=0xee; TL0=0x00; timer ++; if(timer==200) { timer = 0; second ++; } } 按照這個來 你試一試 ![]() |
HAISONC 發(fā)表于 2020-11-28 18:10 [code] //0-59自動計數(shù)器 //跳線設(shè)置:默認 #include<reg51.h> unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char second; unsigned int timer; void main() { TMOD = 0x01; EA=1; //總中斷打開 ET0=1; //定時器中斷打開 second=0; TR0=1; while(1) { if(second<60) {P0=discode1[second/10]; P2=discode2[second%10]; } else if(second==60) {second=0;} } } void int_T0() interrupt 1 using 0 { TH0=0xee; TL0=0x00; timer ++; if(timer==200) { timer = 0; second ++; } }//這個是循環(huán)計時我驗證過了 |
//0-59自動計數(shù)器 //跳線設(shè)置:默認 #include<reg51.h> unsigned char code discode1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char second; unsigned int timer; void main() { TMOD = 0x01; EA=1; //總中斷打開 ET0=1; //定時器中斷打開 second=0; TR0=1; while(1) { if(second<60) {P0=~discode1[second/10]; P2=~discode2[second%10]; } else if(second==60) {second=0;} } } void int_T0() interrupt 1 using 0 { TH0=0xee; TL0=0x00; timer ++; if(timer==200) { timer = 0; second ++; } } 我改了下程序,我的電路是共陽的,所以取反,測試時可行的,你試試 |
|
參與人數(shù) 1 | 黑幣 +20 | 收起 理由 |
---|---|---|
![]() | + 20 | 回帖助人的獎勵! |
驗證過了,程序電路都沒有問題 |
你是有問題,還是叫人幫你寫啊?樓主 |
Powered by 單片機教程網(wǎng)