求大神帮忙看一个简单的单片机C51程序,点亮数码管的,不知道错在哪里,老是报错

2024-11-20 12:39:37
推荐回答(1个)
回答(1):

一个简单问题你
char code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};; 后面多了一个分号,是大全角字符,你把它去掉编译器就不会报错了

#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
//延时程序
void delayMS(uint x)
{
uint i;
while(x--)
{
for(i=0;i<165;i++);
}
}
//主程序
void main()
{ uchar i=0;
P1=0x00;
while(1)
{
P1=~DSY_CODE[i];
i=(i+1)%10 ;
delayMS(300);

}
}