While statement problems

Lights

Is this not the same as Four mode light - Programming Questions - Arduino Forum ?

Did you do as I suggested in reply #7 in that thread and look at the StateChangeDetection example in the IDE ?