为什么51单片机程序设计会出现这种错误,明明是照着视频教的编的 5
compilingmain.c...MAIN.C(25):warningC275:expressionwithpossiblynoeffectMAIN.C(25):err...
compiling main.c...
MAIN.C(25): warning C275: expression with possibly no effect
MAIN.C(25): error C141: syntax error near '='
MAIN.C(26): error C141: syntax error near ';'
MAIN.C(26): error C141: syntax error near '!='
MAIN.C(26): error C141: syntax error near ')'
MAIN.C(29): error C141: syntax error near ';'
MAIN.C(29): error C141: syntax error near '!='
MAIN.C(29): error C141: syntax error near ')'
MAIN.C(31): error C141: syntax error near '='
MAIN.C(32): error C141: syntax error near ';'
MAIN.C(32): error C141: syntax error near ')'
MAIN.C(34): error C172: 'case': missing enclosing switch
MAIN.C(34): error C171: 'break': missing enclosing loop
MAIN.C(35): error C172: 'case': missing enclosing switch
MAIN.C(35): error C171: 'break': missing enclosing loop
MAIN.C(36): error C172: 'case': missing enclosing switch
MAIN.C(36): error C171: 'break': missing enclosing loop
MAIN.C(37): error C172: 'case': missing enclosing switch
MAIN.C(37): error C171: 'break': missing enclosing loop
MAIN.C(39): error C141: syntax error near '='
MAIN.C(40): error C141: syntax error near ';'
MAIN.C(40): error C141: syntax error near ')'
MAIN.C(42): error C172: 'case': missing enclosing switch
MAIN.C(42): error C171: 'break': missing enclosing loop
MAIN.C(43): error C172: 'case': missing enclosing switch
MAIN.C(43): error C171: 'break': missing enclosing loop
MAIN.C(44): error C172: 'case': missing enclosing switch
MAIN.C(44): error C171: 'break': missing enclosing loop
MAIN.C(45): error C172: 'case': missing enclosing switch
MAIN.C(45): error C171: 'break': missing enclosing loop
MAIN.C(47): error C141: syntax error near ';'
MAIN.C(47): error C141: syntax error near ')'
main.c - 31 Error(s), 1 Warning(s).
#include "reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit lsa=P2^2;
sbit lsb=P2^3;
sbit lsc=P2^4;
#define GPIO_key P1;
#define GPIO_dig P0;
u8 key;
u8 code smg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,
0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(u8 i)
{
while(i--);
}
void keydown()
{
u8 a=0;
GPIO_key=0x0f;
if(GPIO_key!=0x0f)
{
delay(1000);
if(GPIO_key!=0x0f)
{
GPIO_key=0x0f;
switch(GPIO_key)
{
case 0x07 :key=0;break;
case 0x0b :key=1;break;
case 0x0d :key=2;break;
case 0x0e :key=3;break;
}
GPIO_key=0xf0;
switch(GPIO_key)
{
case 0x70:key=key;break;
case 0xb0:key=key+4;break;
case 0xd0:key=key+8;break;
case 0xe0:key=key+12;break;
}
while((a<50)&&(GPIO_key!=0xf0))
{
delay(1000);
a++;
}
}
}
}
void main()
{
lsa=0;
lsb=0;
lsc=0;
while(1)
{
juzhen();
GPIO_dig=smg(key);
}
} 展开
MAIN.C(25): warning C275: expression with possibly no effect
MAIN.C(25): error C141: syntax error near '='
MAIN.C(26): error C141: syntax error near ';'
MAIN.C(26): error C141: syntax error near '!='
MAIN.C(26): error C141: syntax error near ')'
MAIN.C(29): error C141: syntax error near ';'
MAIN.C(29): error C141: syntax error near '!='
MAIN.C(29): error C141: syntax error near ')'
MAIN.C(31): error C141: syntax error near '='
MAIN.C(32): error C141: syntax error near ';'
MAIN.C(32): error C141: syntax error near ')'
MAIN.C(34): error C172: 'case': missing enclosing switch
MAIN.C(34): error C171: 'break': missing enclosing loop
MAIN.C(35): error C172: 'case': missing enclosing switch
MAIN.C(35): error C171: 'break': missing enclosing loop
MAIN.C(36): error C172: 'case': missing enclosing switch
MAIN.C(36): error C171: 'break': missing enclosing loop
MAIN.C(37): error C172: 'case': missing enclosing switch
MAIN.C(37): error C171: 'break': missing enclosing loop
MAIN.C(39): error C141: syntax error near '='
MAIN.C(40): error C141: syntax error near ';'
MAIN.C(40): error C141: syntax error near ')'
MAIN.C(42): error C172: 'case': missing enclosing switch
MAIN.C(42): error C171: 'break': missing enclosing loop
MAIN.C(43): error C172: 'case': missing enclosing switch
MAIN.C(43): error C171: 'break': missing enclosing loop
MAIN.C(44): error C172: 'case': missing enclosing switch
MAIN.C(44): error C171: 'break': missing enclosing loop
MAIN.C(45): error C172: 'case': missing enclosing switch
MAIN.C(45): error C171: 'break': missing enclosing loop
MAIN.C(47): error C141: syntax error near ';'
MAIN.C(47): error C141: syntax error near ')'
main.c - 31 Error(s), 1 Warning(s).
#include "reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit lsa=P2^2;
sbit lsb=P2^3;
sbit lsc=P2^4;
#define GPIO_key P1;
#define GPIO_dig P0;
u8 key;
u8 code smg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,
0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(u8 i)
{
while(i--);
}
void keydown()
{
u8 a=0;
GPIO_key=0x0f;
if(GPIO_key!=0x0f)
{
delay(1000);
if(GPIO_key!=0x0f)
{
GPIO_key=0x0f;
switch(GPIO_key)
{
case 0x07 :key=0;break;
case 0x0b :key=1;break;
case 0x0d :key=2;break;
case 0x0e :key=3;break;
}
GPIO_key=0xf0;
switch(GPIO_key)
{
case 0x70:key=key;break;
case 0xb0:key=key+4;break;
case 0xd0:key=key+8;break;
case 0xe0:key=key+12;break;
}
while((a<50)&&(GPIO_key!=0xf0))
{
delay(1000);
a++;
}
}
}
}
void main()
{
lsa=0;
lsb=0;
lsc=0;
while(1)
{
juzhen();
GPIO_dig=smg(key);
}
} 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询