我想点亮一个4位共阳数码管,输出2013四个数字,写的程序如下,用STC89C52RC
开发板仿真,出现了乱码,我感觉程序没错啊
,求大神帮忙
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
code uchar SEG_CODE[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
code uchar array[]={2,0,1,3};
void delay(uint x)
{
uint i;
while(x--) for(i=0;i<120;i++);
}
void main()
{
uint t;
while(1)
{
for(t=0;t<4;t++)
{
P0=0xff;
P2=1<<t;
P0=SEG_CODE[array[t]];
delay(4);
}
}
}
一周热门 更多>