int increment = 1; int val = 0; void setup(){ } void draw (){ if(val >= 10 || val < 0 ){ increment *= -1; } val = val + increment; println(val); }