Asked
— Edited
Resolved by DJ Sures!
Hi guys.
I have some servos set up with joystick buttons and using control command, I have set up some sound effects from a soundboard to play when the buttons are pressed and servos move. Works great.
Here's the thing. I have a servo set up and controlled by joystick 2. What I would also like to do is to play a sound effect I have on the soundboard when this servo is moved, but joystick 2 doesn't have a scripting option on it's configuration menu like the buttons do. Bare in mind I'm still really new and inexperience at using scripts, how do I accomplished this? confused
Cheers, Steve.
Make sure you have the Set Variables checked in ARC's Joystick control...
Create new EZ-Script Control and use this code...
When the new EZ-Script Control with the above code is running, it will loop for ever until STOPPED. The code will check for the joystick position and play a sound according to it's location. You can monitor the variable values for the different joystick positions by looking at the VARIABLE tab when editing scripts.
There are a few ways to accomplish this...
One, a loop with WaitForChange...
Two, a loop with IF for specific position based control...
Or use the joystick variables (you must enable them in the joystick control)
If you are using the same joystick as the Movement Panel and you want sounds when moving forwards, reverse or turning you can use the custom Movement Panel and script the directions in there which can include any controlcommands you need.
And DJ beat me (but I did give more options)
Thanks guys. I will give this a try tommorow morning and let you know how I get on.
Just a quick update. I followed your code DJ, and it worked like a charm. I did take out the sleep() commands as I wanted the sound effects to start instantly and it works great. Thanks so much for that.
Thanks also to Rich for your reply. Yes DJ just picked you to the post, but your help will also come in useful and of course greatly appreciated.
Steve.
Great to hear ... Keep in mind that you will need a Sleep() in the loop, otherwise you will be looping at the speed of your PC and use all your processing power. A Sleep() pauses the CPU and let's other things happen during the Sleep() time
This is why you will always notice a Sleep() in every loop that anyone will share.
Ahh got it. Misunderstood what the sleep() command did in this instance eyeroll. I will put them back in. Thanks for putting me right. While your around, would you mind helping me out with an additional joystick question I have which I posted here in post 11?
Thanks again.