|
最近剛自學 arduino , 照書打的程式, 但是有語法錯誤吧, 找了好久 不知道錯在哪 懇請有空的大神 幫看一下 感恩錯誤訊息是: expected ')' before '{' token
程式如下:
int i;
int j;
int k;
int ledStatus[10];
const int numCols = 3;
const int numRows = 4;
const int debounceDelay = 20;
const int led[] = {10,11,12,13,14,15,16,17,18,19};
const int col[] = {6,7,8};
const int row[] = {2,3,4,5};
const int keyMap[numRows][numCols] = { {1,2,3},{4,5,6},{7,8,9},{10,0,11} };
void setup()
{
for(i = 0; i < numCols; i++)
{
pinMode(col,OUTPUT);
digitalWrite(col,HIGH);
}
for(j = 0; j < numRows; j++)
{
pinMode(row[j],OUTPUT);
digitalWrite(row[j],HIGH);
}
for(k = 0; k <10; k++)
{
pinMode(led[k],OUTPUT);
digitalWrite(led[k],LOW);
ledStatus[k] = LOW;
}
}
void loop()
{
int key=getKey();
if(key >=0 && key<= 9)
{
ledStatus[key] =!ledStatus[key];
digitalWrite(led[key],ledStatus[key]);
}
}
int getKey()
{
int i;
int j;
int key = -1;
for(i=0; i<numCols; i++)
{
digitalWrite(col,LOW);
for(j=0; j<numRows; j++)
{
if(digitalRead(row[j]==LOW)
{
delay(debounceDelay);
while(digitalRead(row[j])==LOW);
key = keyMap[j];
}
}
digitalWrite(col,HIGH);
}
return(key);
} |
|