0

Someone of you can help me with code issue? I got the generic compiling error: error: expected primary-expression before '{' token

with this part of code code:

for (int i=0; i<2; i++) { 

   PotValue[i] = analogRead(PotPin[i]);   //This is the error line

   MappedPotValue[i]=(PotValue[i]+1)/103;

 //SomeCode Here
}

So. My target is to write in PotValue Array all the values of all Pots in Arduino Board

PotValue and MappedPotValue are int arrays of 2 lenght

And PotPin has been declared as:

#define PotPin {A0, A1} // These are two analog pins on arduino board

the for loop is inside a timer interrupt

thx for help

4

2 回答 2

2
analogRead(PotPin[i]);

被解析为:

analogRead({A0, A1}[i]);

这是一个语法错误。C 或 C++ 中没有数组字面量。

于 2013-10-15T19:30:14.857 回答
1

您应该避免使用预处理器。使用它而不是#define

static const int PotPin[] = {A0, A1};

(根据需要调整类型int)。

于 2013-10-15T19:43:50.070 回答