|
scripting issue Riley [7 posts] |
14 year
|
OK I've Really tried to work this out.
I am attempting to control a slider in pololu mini maestro 12 with a logitech attack 3 joystick.
I have named button 9 on the joystick "LIGHTS_ON" and have mapped it to the VBScript Source Program with no problem.
I wrote the following script (along with several variations):
SetVariable "servo_1_value", servo1value + 1500
SetVariable "LIGHTS_ON", lightsOn + 1500
if GetVariable ("LIGHTS_ON")=1 then servo1value=lightsOn+500 end if
I assigned "servo_1_value" to the proper channel in the maestro control module.
This successfully adds the proper value to the control module (centering the value).
However, when the button on the jojstick is pressed, the values remain unaffected.
ANY help would be appreciated.
-Riley
|
|
|
Anonymous |
14 year
|
Riley,
The code looks a little confused ... what are you trying to do when the button is pressed?
Since you are checking the lights_on variable in
if GetVariable ("LIGHTS_ON")=1 then servo1value=lightsOn+500 end if
this will never trigger since in the previous line you are setting the LIGHTS_ON variable to some value +1500 so it is unlikely that the value will ever be 1. I think you mean something more like
SetVariable "servo_1_value", servo1value + 1500
if GetVariable ("LIGHTS_ON")=1 then
SetVariable "servo_2_value", 2500
else
SetVariable "servo_2_value", 500
end if
where servo1 is used for whatever, and servo2 will switch the light switch ... assuming that one end of the servo rotation is on and the other is off.
Or are servo1 and servo2 connected in some way?
STeven.
|
|
|
Riley [7 posts] |
14 year
|
I can see where this does look a bit confused. I am not actually controling a servo at all. I used servo1value as a default since it corresponds to my other scripts. I am actually controling a Dimensions Engineering Pico Switch (relay) that triggers when it receives a positive value from the controller (I assumed +500 was as good as any).
Instead of servo_1_value I probably should have named it picoswitch_value.
So basically I am trying to deliver a +500 value when LIGHTS_ON (button 9 is pressed and have the value terminate when LIGHTS_OFF(button 8) is depressed.
hope this makes sense??
Thank you (again)
-Riley
|
|
|
Anonymous |
14 year
|
Riley,
Ok, that makes better sense. Then it would be more like
if GetVariable ("LIGHTS_ON")=1 then
SetVariable "picoswitch_value", 1
end if
if GetVariable ("LIGHTS_OFF")=1 then
SetVariable "picoswitch_value", -1
end if
Note that as long as you don't change the value of a variable it will not change its value ... so you use the two buttons to change the state of the variable as appropriate ... or you could use one button to toggle the value as another alternative.
If -1 does not appear to switch off the lights try a zero instead as sometimes negative values are not well transmitted to various devices.
STeven.
|
|