Trouble with if command

I just got my Arduino over Christmas and have been playing with the basic blink example. I've changed the delay to a variable so that it can be changed by an if statement.

int ledPin =  13;    // LED connected to digital pin 13
int a = 0;        // lopp count
int d = 5000;    // starting delay time

void setup()   {                
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);     
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                     
{
  a + 1;    // adds 1 to the loop count
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(d);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(d);                  // wait for a second
if (a > 10);    // once the loop count reaches 10,
  {
  d = 50;    // delay is set to 50 ms
  }

}

As you can see i've got it so it will count the number of times the program loops. After it reaches the designated 10 loop it changes the delay. When i verify the program everything checks out OK but the program doesn't act as i want it too. the LED will turn on for 5 sec and off for 5 then it goes directly to the fast blinking. I can't seam to get it to go threw 10 loops of the long blinking before going to the fast blinking. I must be missing something about the if statement here cause the delay shouldn't only change if the if statement is true. Next i want to ad a switch to this so that when pressed it resets the loop counter and the delay.

Ok i think i found the problem.

i was missing a piece of code. it should have been

int d = 50;       // delay is set to 50 ms

so now it doesn't go directly to the fast blink after the first long blink but now its like its not finding the if statement true at all and isn't changing the delay. so something still isn't right.

a + 1;    // adds 1 to the loop count

No, it doesn't. "a++;" or "a = a + 1;" does.

if (a > 10);    // once the loop count reaches 10,
  {
  d = 50;    // delay is set to 50 ms
  }

Remove the semicolon on the 'if' line as so

if (a > 10)    // once the loop count reaches 10,
  {
  d = 50;    // delay is set to 50 ms
  }

As it was it would be processed seperately and behave as you described.

Don't put the int in the d=50; line , it then becomes a local variable that only works in the one statement. The a + 1 line should be modified as the other poster says.

if (a > 10)    // once the loop count reaches 10,

If you want it to count to 10 it should be

if (a >= 10)    // once the loop count reaches 10,

As it is it it will do 11.

That fixed it. My wife just pointed out the misplaced ; for me and it works. Thanks guys.

I very recently blamed Vista and a java update for failure of arduino.exe to compile. Now I find that opening processing.exe gets things moving. HOWEVER I now find the sketch compiler is giving strange errors.

I have cut and pasted several versions of Blink including obvious screen dumps with so far bad results. Typically, ....(ledPin,OUTPUT); is greeted by ..cant find anything called OUTPUT... Editing Sketch has no effect.

Is it possible that the wrong ASCII values are being presented to the Sketch ? I am sore and weary with lack of progress. John.

Rather than cutting-and-pasting, have you tried File + Examples + Digital + Blink? Do you get the same errors that way?

What does this have to do with "Trouble with if command"?

Wow nice thread jacking.

thread jacking... I apologise. At wits end and clumsy, posted wrong item. Anyway, systems clearout and reload of 0017 has me working as advertised. One small step....