Hi Flotulopex. The FOR - NEXT is confusing to me too. I use a different routine from a basic compiler I used a long time ago. This is a snip from a motor speed controller that controls the speed of an electric cart. At the start of the program, LEFTRAMP is made 0. If the speedpot is reduced while running, it will also ramp down.

LEFTON: 'TURNS ON LEFT MOTOR FOR RIGHT TURN
ADCIN 2, SPEEDPOT
IF LEFTRAMP < SPEEDPOT Then LET LEFTRAMP = LEFTRAMP + 1
IF LEFTRAMP > SPEEDPOT Then LET LEFTRAMP = LEFTRAMP - 1
Pause 1 'CONTROLS THE RAMP-UP DELAY
HPwm 1,LEFTRAMP,15000 'PWM OUTPUT DUTYCYCLE LIMITED TO SPEEDPOT
GoTo LEFTON