# Increasing and decreasing value between a range

I try to have a range 0 to 20. I want to use keyboard in and for positive and m for negative.
so when I press on ‘n’ the range go up from one and block at 20, when I press ‘m’ the number decrease from one and stop at 0.
I can play between 0 and 20 depending on what I press.
I look easy, but I did not find the way to do that.
It’s probably easy. thanks for any advice.

Hey,

the Count CHOP and the KeyboardIn CHOP are your best friends for this.

The Count CHOP has 3 Inputs:

• First Input is the channels to Count and it also is the trigger, when the incoming channel goes from 0 to 1 it will increase the count by a certain value
• Second input is a Reset Trigger - sending in a value greater than 1 will reset the Count
• Third Input is the value to increment the Count CHOP by. This is especially interesting for your purpose as you can also use a negative value here meaning that the increment becomes a decrease.

You set up the Keybard In CHOP so that you get your 2 desired keys (watch out for the Key Order parameter). Append a Math CHOP and add up the 2 channels meaning you will always get a positive value when either key is pressed. The output is used for the first Input in the Count CHOP.
Next in a new branch, select out the key you want to use to decrease the value with. Append a Math CHOP to the Select and on the Range Page set the “To Range” parameter to 1 and -1. Use this output as the input to the Increment Value Input of the Count CHOP.

The Count CHOP also has the ability to set limits. So Clamping the values at 0 and 20 should not be a problem.

Cheers
Markus

1 Like

BIG THANKS, for the great explication.
I have played a lot with thos nod, but was not able to come up with the best set up.
now everything works perfectly