Error in void loop()

int led=13;
int led2=12;
int on_time=1000;
int off_time=1000;

void setup() {

pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
digitalWrite(led, LOW);
digitalWrite(led, LOW);

}

void loop() {

for(int a=1;a<=5;a=a+)
{
digitalWrite(led, HIGH);
delay(on_time);
digitalWrite(led,LOW);
delay(off_time);
}

}

when i try to upload this code i am getting an error compiling
sketch_aug24c.ino: In function ‘void loop()’:
sketch_aug24c.ino:21:22: error: expected primary-expression before ‘)’ token

for(int a=1;a<=5;a++)

oh thank you it worked

C ++ syntax is very important and easy to get wrong if you're just starting out.
Double-check what you've written when something doesn't work the way you expect

Now increment 5 to 10, or try it without the for loop.
Why don't you notice any difference?

const int led=13;
const int on_time=1000;
const int off_time=1000;

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

void loop() {
   digitalWrite(led, HIGH);
   delay(on_time);
   digitalWrite(led,LOW);
   delay(off_time);
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.