Student question on if statement not working


greetings:

i trying build "knight rider" type led setup.

i want increase it's delay increments certian point , have reset it's original delay.

as have now, goes in 1 direction , slow in other.

int timer = 100;

void setup(){
  (int ledpin = 2; ledpin <8; ledpin++){     //sets each pin output , named ledpin
    pinmode (ledpin, output);
  }
}
void loop(){
  (int ledpin = 2; ledpin <8; ledpin++){     //loops ledpin lowest highest
  digitalwrite (ledpin, high);    //ledpin on
  delay(timer);
  digitalwrite(ledpin, low);     //ledpin off
  }
  for(int ledpin = 7; ledpin >=2; ledpin--){     //loops ledpin highest lowest
     digitalwrite(ledpin, high);     //ledpin on
     delay(timer);
     digitalwrite(ledpin, low);
 
    timer = timer + 100;
  }
    { if(timer>=700);
     {
      timer=100;
  }
    }
}

code: [select]
if(timer>=700);
the semicolon not belong @ end of if statement.  semicolon ends statement , next statement executed unconditionally.

please read "how use forum" stickies see how format , post code.


Arduino Forum > Using Arduino > Programming Questions > Student question on if statement not working


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts