验证过了,程序电路都没有问题 |
统一回复下,这是做的一个分享作品,不是求帮的 |
#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 发表于 2020-11-28 18:10 [code] //0-59自动计数器 //跳线设置:默认 #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 ++; } }//这个是循环计时我验证过了 |
//0-59自动计数器 //跳线设置:默认 #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 ++; } } 我改了下程序,我的电路是共阳的,所以取反,测试时可行的,你试试 |
|
验证过了,程序电路都没有问题 |
你是有问题,还是叫人帮你写啊?楼主 |