two number boxes controlling 4 toggles
Hallo.
I'm quite new in Max and need a little help with the following:
I have two number boxes. The first one (X) has a range of -62 till 63 and the second one (Y) from -116 till 117.
According to the 8 possible movements of the numbers listed below (increasing or decreasing), the 4 toggles have to behave like described.
If X increase toggle 2 and 4 are ON
If X decrease toggle 1 and 3 are ON
If Y increase toggle 1 and 2 are ON
If Y decrease toggle 3 and 4 are ON
If X and Y increase toggle 2 is ON
If X and Y decrease toggle 3 is ON
If X decrease and Y increase toggle 1 is ON
If X increase and Y decrease toggle 4 is ON
If there is no movement for more than 0.5 seconds all toggles should be off.
Is there something like an if then function that I could use?
Any help is much appreciated.
Josef
Hi Josef,
here is a rough-in on one approach to one channel -- there are a million ways to do things like this in Max. I have minimal comments, so you can learn as you go!
\M
Thank you so much Mattyo! This is a great help for me.
Somehow your patch only works if I switch directions, not if I stop and continue in the same direction.
Can you suggest how to solve that?
After trying out many things I still can't figure out how I can distinguish between one or two number boxes increasing or decreasing.
Is there a switch that switches only if it gets two values as inputs?
Any suggestion is very welcome. I'm learning a lot here.
Many thanks, Josef
hei josef,
as for your later question – maybe this helps:
once again (: .. how ever this might very well be doable a bit more clever, but see if it serves your purpose
Yet another approach Delay is set to 2500 ms adjust as you like.
@maroy: i think you accidentally copied mine for your code! would you repost your approach?
@Benniy I did indeed (sorry), try my original post now.
Thanks a lot Benny and Maroy.
Your patch does the job Maroy.
Only if I connect it to my joystick output (connected via Arduino and Maxuino), which is controlling the two number boxes, it doesn't work because the joystick gives a constant output, and even if the numbers in the number boxes are not changing, they are banged continuously. And that doesn't work with your patch.
Is there a way to make a bangy number box a not bangy one?
If you place a [change] object before the number boxes, it will only output if the values change.
What do you mean by "bangy" number box?
Awesome Nikolas! Thank you.
With a bangy number box I mean a number box that constantly sends out bangs even when the number isn't changing.
The [change] object works.