Code: Select all
lightMode = lightMode%4 + 1;
Moderators: adafruit_support_bill, adafruit
Code: Select all
lightMode = lightMode%4 + 1;
actually modulus is not terribly efficient on a li'l chip with no hardware divide. as long as your division is by a power of 2, though, you can go with...nathan42100 wrote:A more efficient way in my opinion for the lightMode variable would be to use a modulus:Code: Select all
lightMode = lightMode%4 + 1;
Code: Select all
lightmode = (lightmode + 1) & 3;
Code: Select all
x & (n - 1)
Code: Select all
x % n