void setup() {
pinMode(11, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
if
(digitalRead(2) == HIGH);
{
digitalWrite(11, HIGH);
}
else
{
digitalWrite(11, OUTPUT);
}
}
error: 'else' without a previous 'if'
void setup() {
pinMode(11, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
if
(digitalRead(2) == HIGH);
{
digitalWrite(11, HIGH);
}
else
{
digitalWrite(11, OUTPUT);
}
}
error: 'else' without a previous 'if'
There's one "else" in that sketch. It can't be that hard to figure out which "if" it doesn't relate to.
Hint: Too many ";"
Have a read through this too: How to post code properly
Pete
if(someCondition) ;<<<<<<Any semicolon here is generally a mistake