Change variable every other loop

how do i make i3 equal 1, then make it equal 8 in the loop after, 1 again in the loop after and so forth?

// start with i3 = 1
i3 = 1;
// When you want to flip value
i3 = 9 - i3;


Get to know the Modulus (Modulo) operator:


You can look up frameCount in the references; this can be any counter in your code.