For loop too short

Hello so i wrote function that should turn on and off two pins for 100 times with delay(500)x2, but instead it blinks for 10-25 times (sometimes longer sometimes shorter). Can someone tell me what I'm doing wrong? Using arduino leonardo.

void blink()
{
for(int i=0; i < 100; i++)
{
digitalWrite(5, true);
digitalWirte(6, true);
delay(500);
digitalWrite(5, false);
digitalWrite(6, false):
delay(500);
}
}

Can someone tell me what I'm doing wrong?

  1. Not posting all of your code.
  2. Not using Serial.print() statements to debug.

Post your actual code. I know that what you have posted here is not really your actual code because it has a typo and will not compile.

Aside from the typo, the code looks OK. That means the problem is either elsewhere in your code or in your hardware, neither of which we can see.

(EDIT) Make that TWO typos. I missed the one where you put a ':' where you needed a ';'.

The code below which is your blink() in a complete sketch, with your errors fixed and 500 reduced to 50 to save time, and a Serial.print(i), prints correctly up to 99.

void setup()
{
  Serial.begin(9600);
  Serial.println("start");
  blink();
  Serial.println("end");

}

void loop()
{

}

void blink()
{
  for (int i = 0; i < 100; i++)
  {
    digitalWrite(5, true);
    digitalWrite(6, true);  //not Wirte
    delay(50);
    digitalWrite(5, false);
    digitalWrite(6, false); // ; not :
    delay(50);
    Serial.println(i);
  }
}
.
.
.
.
94
95
96
97
98
99
end