For loop keeps looping

I don’t why this is happening but when the initialization variable is a byte instead of integer the loop doesn’t break after hitting it’s max and keeps repeating.

So this doesn’t go to the second i value but keeps looping with the fadeValue

for (int i = 0; i < 3; i++) {
    for (byte fadeValue = 0; fadeValue <= 255; fadeValue++) {
      analogWrite(Pin[i], fadeValue);
      delay(30);
    }
    analogWrite(Pin[i],0);
  }

and this works just fine

for (int i = 0; i < 3; i++) {
    for (int fadeValue = 0; fadeValue <= 255; fadeValue++) {
      analogWrite(Pin[i], fadeValue);
      delay(30);
    }
    analogWrite(Pin[i],0);
  }

any body an idea why?

  for (byte fadeValue = 0; fadeValue <= 255; fadeValue++)

When fadeValue reaches 255 the limit condition will still be true so fadeValue is incremented and becomes 0 so the loop repeats

Because the condition in that for loop is always true. A byte fadeValue will go from 0-255 then when you add 1 it overflows and become 0 again.

A so it's the problem of overflowing, thanks that makes sense