
还有,你的数码管接法也不对啊
看你的排阻接法,你的数码管要用共阴极的
当加到9之后,再按一下,是不是又恢复到0啦???
下面是更改的回答
#include<reg51.h>unsigned char a
unsigned char code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x67}
void init(void)
{
EA=1
EX0=1
IT0=1
}
void main(void)
{
init()
while(1)
{
P0=table[a]
}
}
void EX_0(void) interrupt 0
{
a++
if(a>9)
a=0
}
望采纳
这个以前做过,给:#include <AT89X51.H>
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f}
unsigned char Count
void delay10ms(void)
{
unsigned char i,j
for(i=20i>0i--)
for(j=248j>0j--)
}
void main(void)
{
Count=0
P0=table[Count/10]
P2=table[Count%10]
while(1)
{
if(P3_7==0)
{
delay10ms()
if(P3_7==0)
{
Count++
if(Count==100)
{
Count=0
}
P0=table[Count/10]
P2=table[Count%10]
while(P3_7==0)
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)