【发布时间】:2015-01-04 12:50:29
【问题描述】:
我在 atmel studio 中遇到此代码错误
错误是:expected ')' before numeric
这是我的代码(我用它作为 atmega32a 的键盘代码):
#include <util/delay.h>
#define c1 PINB 4
#define c2 PINB 5
#define c3 PINB 6
#define c4 PINB 7
unsigned char scan[4]={0XFE,0XFD,0XFB,0XF7};
unsigned char arrkey[16]={1,2,3,20,4,5,6,30,7,8,9,40,10,0,11,50};
unsigned char keypad() {
unsigned char r,c,k;
DDRB=0X0F;
PORTB=0XFF;
while(1) {
for (r=0; r<4; r++) {
c=4;
PORTB=scan[r];
_delay_us(10);
if(c1 == 0) c=0;
if(c2 == 0) c=1;
if(c3 == 0) c=2;
if(c4 == 0) c=3;
if (!(c==4)) {
k=arrkey[(r*4)+c];
while(c1==0);
while(c2==0);
while(c3==0);
while(c4==0);
_delay_ms(50);
return k;
}
}
}
}
【问题讨论】:
-
你能正确缩进你的程序吗?
-
这个错误发生在哪一行?
-
在所有只有一个语句的 if 代码中