想让数码管显示特定数字,有信号但是一直没办法显示出来,大神帮忙看看是为什么
单片机程序如下:
#include <reg51.h>
unsigned char duanma[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
unsigned int shuzi;
sbit yi=P1^1;
sbit er=P1^0;
void delay();
void main()
{
shuzi=16;
while(1)
{
P2=0x00;//很重要,否则数码管很可能无法正常显示
yi=0;
er=1;
P2=duanma[shuzi%10];
delay();
yi=1;
er=0;
P2=duanma[shuzi/10];
delay();
}
}
void delay()
{
unsigned int i,j;
for(i=0;i<100;i++);
for(j=0;j<10;j++);
} |