'If' was not declared in this scope

Hi there,

I am totally new in using Arduino.

I tried to write a little sketch with two LED and one switch. Unfortunately the software wants me to make a declaration for the "if"-formula.

You can find the code below. I would be grateful, if anybody can give me a hint (what do I have to declare and where do have to declare it?). Many thanks in advance.

void setup()

{ pinMode(7, OUTPUT); pinMode(8,OUTPUT); pinMode(4, INPUT);

}

void loop()

{ If (digitalRead(4)== HIGH); { digitalWrite(7, HIGH); digitalWrite(8, LOW); } else { digitalWrite(7, LOW); digitalWrite(8, HIGH); } }

if is if. Small i.

C and C++ are case-sensitive languages.

And since the conditional is "if (...)", "If(...)" looks to the compiler like you're calling a function called If() which of course doesn't exist, hence the error you're getting.

In addition, if statements rarely end in semicolons.

To be precise, if statements never end in semicolons. It is its sub-statements that might end in semicolons.

By placing that ; after the ), the author of the code effectively supplied an empty statement for the true branch of that if. Thus the rest of the code no longer belongs to that if and that else is orphaned.

Many thanks for your tips!