Compile error loop

I am trying to get the led to blink 5 times but I get the following error,

led_increment_loop.cpp: In function ‘void loop()’:
led_increment_loop:13: error: expected `)’ before ‘,’ token

here is the code

const int led = 11; // declare pin 11 as led

void setup()

{
pinMode(led, OUTPUT);

}

void loop()

{
if ( int i =0, i < 5, i++) //increment by one until it reaches 5 blinks 5 times

digitalWrite(led,HIGH);
delay(1500);
digitalWrite(led,LOW);
delay(5000);

}

I am using the latest IDE

if ( int i =0, i < 5, i++) //increment by one until it reaches 5 blinks 5 times

What is that supposed to be?

I think you mean for that to be a “for”, not an “if”, and the sub clauses separated by a ; not a ,

sorry I have been busy running around today, thanks for pointing it out somertimes you just need that second person to help you see the obvious.

majenko:

if ( int i =0, i < 5, i++) //increment by one until it reaches 5 blinks 5 times

What is that supposed to be?

I think you mean for that to be a “for”, not an “if”, and the sub clauses separated by a ; not a ,

And furthermore, you need to enclose the statements you want to loop with curley braces ‘{’ and ‘}’.

Something like this:

const int led = 11; // declare pin 11 as led

void setup()
{
   pinMode(led, OUTPUT);
}

void loop()
{
   for ( int i = 0, i < 5, i++) //increment by one until it reaches 5 blinks 5 times
     {
        digitalWrite(led,HIGH);
        delay(1500);
        digitalWrite(led,LOW);
        delay(5000);
      }
}

However, since loop repeats forever, after it blinks 5 times, it will return from loop, and loop will be called again.

for ( int i = 0, i < 5, i++) //increment by one until it reaches 5 blinks 5 times

Don’t forget those semicolons:

for ( int i = 0; i < 5; i++) //increment by one until it reaches 5 blinks 5 times

Whoops, you are right, in cutting and pasting the code, I didn’t even notice them.