刚学51
单片机,但是运行这个流水灯程序的时候出现了错误,下附代码和运行结果,真心求解。
#include<reg52.h>
sbit ADDR0=P1^0;
sbit ADDR1=P1^1;
sbit ADDR2=P1^2;
sbit ADDR3=P1^3;
sbit ENLED=P1^4;
void main()
{
ADDR0=1;
ADDR1=1;
ADDR2=0;
ADDR3=1;
ENLED=0;
unsigned int i = 0;
unsigned char cnt=0;
while(1)
{ P0=~(0x01<<cnt);
for(i=0;i,20000;++i)
cnt++;
if (cnt>=8)
{
cnt=0;
}
}
}
运行结果:
Build target 'Target 1'
assembling STARTUP.A51...
compiling led流水灯.c...
LED流水灯.C(16): error C141: syntax error near 'unsigned'
LED流水灯.C(16): error C202: 'i': undefined iden
tifier
LED流水灯.C(17): error C141: syntax error near 'unsigned'
LED流水灯.C(17): error C202: 'cnt': undefined identifier
LED流水灯.C(20): error C202: 'cnt': undefined identifier
LED流水灯.C(21): error C202: 'i': undefined identifier
LED流水灯.C(22): error C202: 'cnt': undefined identifier
LED流水灯.C(23): error C202: 'cnt': undefined identifier
LED流水灯.C(25): error C202: 'cnt': undefined identifier
Target not created
一周热门 更多>