单片机89c51,帮我编个C程序,顺便说一下用KeiluVision3仿真调试软件的调试步骤

2024-11-12 10:22:51
推荐回答(3个)
回答(1):

#include

sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;

sbit p25=P2^5;
sbit p26=P2^6;

typedef unsigned char uint8;

code uint8 num[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90,};
uint8 count,shi,ge,i;
delay()
{
uint8 i=1000;
while(i--);
}

display()
{
shi=count/10;
ge=count%10;

p25=0;
P0=num[shi];
p25=1;
p26=0;
P0=num[ge];
p26=1;

}
main()
{
while(1)
{
if(p20==0)
{
delay();
if(p20==0)
{
count++;
}
}
if(p21==0)
{
delay();
if(p21==0)
{
count--;
}
}
if(p22==0)
{
delay();
if(p22==0)
{
count=0;
}
}

display();
}

}

回答(2):

..buh

回答(3):

这个简单,我能帮你做,但图在哪里?