detecting change to pass a value with a threshold
Hi, I'm doing a project for uni, for which I'm using an arduino. Because of the load of the components or sth. the values coming into max are changing, which is not good because I've implemented a shift funktion. So all values, which are using shift, are overwritten, when I press shift. I tried to use a smaller quantization, but there are obviously still changes in some cases. I need like a filter, that detects a change of like 6 steps before it passes a value. I provided a drawing fo the problem.
.png)
I tried to build a filter like this with a counter and a gate, but it doesn't work at all. Also I tried smoothing with line, but that doesn't solve anything either.
So this would be the counter. How do I detect, that there is there is no more change?

cycle 6
I guess I could do this with a delay, which is driven by the bangs generated by the dial, but if someone has a better idea, I'd like to know. My idea seems a little to complicated
@DOUBLE_UG thank you very much. didn't know this one.
I'm just wondering if we have understood your question properly? When you say "steps", do you mean sequencer or timing steps or are you actually referring to the output value of the dial.
I can imagine a scenario where the output of the dial is flickering in a small range, say between 97 and 103, and that you want to filter this minor variation out but that you then want to capture the larger changes. If that is what you mean then this would do the trick:

The threshold for the filter can be set in the number object at the top (set to 5 in the example). The gate at the bottom is controlled by the clock/counter in the middle. Essentially, once the threshold has been exceeded, the dial output will be passed through the gate for at least one second (set by the second argument of the counter in tenths of a second) and all the while the changes in the dial value exceed the threshold (done by resetting the counter to 1 every time the bang is triggered by the if statement).
if you problem is analog input jitter or fluctuations,
then you should do the filtering in arduino,
then send clean 0 - 127 to max.
If you can't do so, then rather send full 0 - 1023 scale and
do filtering in max, and then scale to 0 - 127
Goal is to receive full range 0 - 127 without values being droped
because of the filter.
@ANDY MASKELL Sry, haven't read your post. The potentiometer had very bad flickering and I wanted to filter this out. And it was changing between values, when I use the switches aswell. That was a range from like 4-6. Thank you for your idea. It's way better than mine :D