带循环的arduino代码错误

时间:2016-10-11 16:55:50

标签: if-statement arduino void

任何人都可以帮我解决此错误:error: expected unqualified-id before 'void'

这就是代码。

int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int led8 = 8;
int led9 = 9;
int brightness = 0;
int fadeAmount = 3,
void setup()
{
    pinMode(led2,OUTPUT);
    pinMode(led3,OUTPUT);
    pinMode(led4,OUTPUT);
    pinMode(led5,OUTPUT);
    pinMode(led6,OUTPUT);
    pinMode(led7,OUTPUT);
    pinMode(led8,OUTPUT);
    pinMode(led9,OUTPUT);
}
void loop()
{
  digitalWrite(led2,HIGH);
  delay(1000);
  digitalWrite(led2,LOW);
  delay(1000);
  analogWrite(led3,brightness);
  digitalWrite(led4,HIGH);
  delay(1000);
  digitalWrite(led4,LOW);
  delay(1000);
  analogWrite(led5,brightness);
  analogWrite(led6,brightness);
  digitalWrite(led7,HIGH);
  delay(750);
  digitalWrite(led7,LOW);
  delay(750);
  digitalWrite(led8,HIGH);
  delay(600);
  digitalWrite(led8,LOW);
  delay(600);
  analogWrite(led9,brightness);
  brightness = brightness + fadeAmount;
  if(brightness ==0 || brightness ==255);
  {fadeAmount= -fadeAmount;}
}

1 个答案:

答案 0 :(得分:0)

void setup()之前的行上有逗号而不是分号。如果您将int fadeAmount = 3,更改为int fadeAmount = 3;,那么它将会正常运作。