counting from value to value, slider value goes fluently to new slider value

plumbum's icon

Hi, Im trying hard to fade fluently from one value to another. trying to control servos slowly from old value to new. Basically try to imagine slider on one left and slider on right. If I click on left one, the right one slides to the new value fluently, in speed x (metro for ex.).

patch: https://cycling74.com/forums/slowdown-servo-move
I tried to solve that using [counter], but its hard to set up correctly when it should count up and down. It not always works, for ex. if the new number is not bigger than the number before the previous.

Perhaps there is some object making this really easy.

brendan mccloskey's icon

If I understand your request, I think [line] might help here: [slider]->[$1 100] message -> [line] -> [slider]. That's the simplest way to do it in Max; but i've never used serial-output to control servos.

plumbum's icon

great! now I will just relativize speed for different values to fade (now same time to fade from 1-100 as 1-10) and its done. :)
thanks

brendan mccloskey's icon

not sure about the last bit, but maybe look at: [maximum], [peak], [scale] and related objects; you might be able to cobble something together - there are some geniuses on this forum who could do this in their sleep...

plumbum's icon

scale: I though so.
geniuses: I'm sure about that. ;)

brendan mccloskey's icon

I usually title such requests with the words 'simple math problem', and the responses are many, fast, and always right..good luck

Tim Lloyd's icon

This should get you started (It does what you need if I'm understanding correctly).

Max Patch
Copy patch and select New From Clipboard in Max.

Although there is a problem with the method, in that if you set a new destination value before line has finished ramping, line might have to "jump" to the old destination value (now the starting value). It may not be an issue unless your ramp time is long though.

spinit's icon

Thanks a lot Tim!

Saved my project.