单片机C51一个开关控制8个LED灯编程纠正

#include<reg51.h>
#define uchar unsigned char
uchar led[5]={0x7e,0x3c,0x18,0x00,0xff};
uchar num;
sbit key=P1^0;
main()
{
P0=0xff;
num=0;
while(1)
{
if(key==0)
{
while(key==0);
P0=led[num];
num++;
num%=5;
}
}
}
提示C(9):error C141: syntax error near ‘num’ Tar get not created

你这个程序没有什么问题的,编译是可以通过的。你没有建工程吧?如下图编译结果是对的。

温馨提示:内容为网友见解,仅供参考
第1个回答  2018-01-17

没有问题啊,你再试试

相似回答