单片机错误
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define wei P1;
#define duan P0;
sbit D1= P2^0;
sbit key1= P3^4;
uchar code table[16]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
while(1)
{
if(key1==0)
{delay(10);
if(key1==0)
{ num=0;
num++;
if(num==10)
num=0;
D1=0;
while(!key1);
delay(10);
while(!key1);
}
}
else
{
D1=1;
wei=0x00;
duan=table[num];
}
}
}
4\4.C(43): error C141: syntax error near '='
4\4.C(44): error C141: syntax error near '='
为什么错了
#define uchar unsigned char
#define uint unsigned int
#define wei P1;
#define duan P0;
sbit D1= P2^0;
sbit key1= P3^4;
uchar code table[16]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
while(1)
{
if(key1==0)
{delay(10);
if(key1==0)
{ num=0;
num++;
if(num==10)
num=0;
D1=0;
while(!key1);
delay(10);
while(!key1);
}
}
else
{
D1=1;
wei=0x00;
duan=table[num];
}
}
}
4\4.C(43): error C141: syntax error near '='
4\4.C(44): error C141: syntax error near '='
为什么错了
这两个等号输入法对不对?
#define duan P0;
#define wei P1;
的后面定义不能有“;”号
#define duan P0;
#define wei P1;
分号不能有。