2013-10-15 70 views
0

你們中的某個人可以幫我解決代碼問題?我得到了通用的編譯錯誤: 錯誤:預期前主表達式「{」令牌錯誤:在'{'令牌之前預期的初級表達式

與代碼這部分代碼:

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陣列寫在Arduino板所有花盆的所有值

PotValue和MappedPotValue是

而且PotPin已被宣佈爲2 lenght的INT數組:

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

的對循環是一個定時器中斷

THX內尋求幫助

+0

'analogRead'採取了什麼參數? – 0x499602D2

回答

2
analogRead(PotPin[i]); 

被解析爲:

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

這是一個語法錯誤。 C或C++中沒有數組文字。

1

您應該避免預處理器。用此代替#define

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

(適應型int根據需要)。

相關問題