ELSE WITHOUT A PREVIOUS 'IF'

Hi. Anyone knows what this means or how could I change it so it could work. I void loop() is it that I need more than one huge bracket? Thanks!

const int LED_BUILTIN = 13;

const int pin12 = 12;

int val = 0;

void setup()

{

pinMode(LED_BUILTIN,OUTPUT);

pinMode(pin12,OUTPUT);

}

void loop()

{

if(LED_BUILTIN == LOW);

digitalWrite(LED_BUILTIN,HIGH);

else if(LED_BUILTIN > val);

digitalWrite(LED_BUILTIN,LOW);

else

digitalWrite(pin12,HIGH);

digitalWrite(pin12,LOW);

}

Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:249:0, from sketch_oct26a.ino:1: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard/pins_arduino.h:47:21: error: expected unqualified-id before numeric constant

define LED_BUILTIN 13

^ sketch_oct26a.ino:1:11: note: in expansion of macro 'LED_BUILTIN' sketch_oct26a.ino: In function 'void loop()': sketch_oct26a:13: error: 'else' without a previous 'if' sketch_oct26a:15: error: 'else' without a previous 'if' 'else' without a previous 'if'

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

Your loops are not correct in the first place.

Also please use code tags.

[tag] Code goes here [/tag] - replace the word tag with code. Edit your post to correct this.

Example if:

void loop(){ // squiggle for start of loop code

if (a > b) { " if a is bigger than B...do this" }     // note the two enclosing squiggles.
else { "otherwise do this" }    // note the two enclosing squiggles.


} //squiggle for end of loop code

When formatted as standard...it should look like this:

if (a > b) {
    print("A is bigger than B");
    }

else {
    print("A is not bigger than B");
    }

You shouldn't end your if statements with a ";".

When formatted as standard...it should look like this:

No, it should look like this:

if (a > b)
{
    print("A is bigger than B");
}
else
{
    print("A is not bigger than B");
}

Remove this line. LED_BUILTIN is a predefined constant.

const int LED_BUILTIN = 13;

hi

this compile

#define LED_BUILTIN 13;
int pin12 = 12;

int val = 0;

void setup()

{
pinMode(pin12, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()

{
  
if(LED_BUILTIN == LOW){
  digitalWrite(LED_BUILTIN,HIGH);
  }
  
else if(LED_BUILTIN > val){
  digitalWrite(LED_BUILTIN,LOW);
  }
else {
digitalWrite(pin12,HIGH);
digitalWrite(pin12,LOW);

}
}

PaulS: No, it should look like this:

if (a > b)
{
    print("A is bigger than B");
}
else
{
    print("A is not bigger than B");
}

Oooops sorry. The little python I know crept in there!

a55830: hi

this compile

#define LED_BUILTIN 13;
int pin12 = 12;

int val = 0;

void setup()

{ pinMode(pin12, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); }

void loop()

{   if(LED_BUILTIN == LOW){  digitalWrite(LED_BUILTIN,HIGH);  }   else if(LED_BUILTIN > val){  digitalWrite(LED_BUILTIN,LOW);  } else { digitalWrite(pin12,HIGH); digitalWrite(pin12,LOW);

} }

You don't need that either. This line is already in "pins.arduino.h":

#define LED_BUILTIN 13

It is predefined. You do not need to define it!

A #define has no ";"