Why are the Do While loops not stopping?
change &gt;= and &lt;= to &gt; and &lt; respectively.
You want it to stop at 0, but your do-while will do another round, since 0&gt;=0 is true. So your code only stops at -1 and 256.
When legThreeBrightness is 256 it should be counting down, but your if (legThreeBrightness == 255){ doesn't detect this, so the code will continue counting up. I'd probably change this line to if (legThreeBrightness &gt;= 255){ to prevent this from ever happening (which it shouldn't, but still).