[英]error: expected primary-expression before '{' token
有人可以帮助我解决代码问题吗? 我收到了一般的编译错误:错误:'{'令牌之前的预期主表达式
使用这部分代码:
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
}
所以。 我的目标是在PotValue Array中写入Arduino板中所有Pot的所有值
PotValue和MappedPotValue是长度为2的int数组
PotPin已声明为:
#define PotPin {A0, A1} // These are two analog pins on arduino board
for循环位于计时器中断中
寻求帮助
analogRead(PotPin[i]);
被解析为:
analogRead({A0, A1}[i]);
这是语法错误。 C或C ++中没有数组文字。
您应该避免使用预处理器。 使用它代替#define
:
static const int PotPin[] = {A0, A1};
(根据需要调整int
类型)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.