Go Down

Topic: Error message : eslse without a previous if (Read 67 times) previous topic - next topic

Simsim3374

Code: [Select]

int green = 2;
int button = 4;
void setup() {
  pinMode(green, OUTPUT);
  pinMode(button, INPUT);
}

void loop() {
  if(digitalRead(button));
  {
    digitalWrite(green, HIGH);
  }
  else
  {
    digitalWrite(green, LOW);
  }
}



The error message is on the else : else without a previous if but I write if

sayHovis

The ; on the end of this, ended the "if" early....

Code: [Select]
if(digitalRead(button));



Go Up