|
Re: Motor Ramp Up/Ramp Down Function
you only need like 3 variables in a function: target(the joystick value), output value(the current pwm value), rate(the rate of change).
if((target - output) > rate)
output += rate;
if((output - target) > rate)
output -= rate;
else
output = output;
this is just to explain how to do it.
Make sure all the variable being compared in the if statement are int. Otherwise it will execute for example if it results as (-5 > 4), if they are unsinged variables.
just write a function and you can use it anywhere.
|