this is what i am trying to do. i am trying to control a servo with muliple inputs. i would like the servo to stay at 6046 when no signal is active. i would like to use 4 inputs (buttons) to control the servos position. 2 inputs for 4000 position and 2 inputs for 8092 position.
i am far from a c++ writter, but i have been tring to get this to work on my own and its driving me nuts. if you could help me, i would greatly apprciate it.
here is what i came up with but it wont work?
begin
button_a if
8092 else
button_b if
4000 else
button_c if
8092 else
button_d if
4000 else
endif
endif
endif
endif
6046 0 servo # set servo 0 based to the value
repeat
sub
button_a
1 get_position 500 less_than
return
sub
button_b
2 get_position 500 less_than
return
sub
button_c
3 get_position 500 less_than
return
sub
button_d
4 get_position 500 less_than
return
This code involves 1 servo and 2 buttons. When no buttons are pressed, the position of the servo is 6046. When button_a is pressed, the servo moves to position 4000, and when button_b is pressed, the servo moves to 8092.
# When the script is not doing anything else,
# this loop will listen for button presses. When a button
# is pressed it runs the corresponding sequence.
begin
button_a if sequence_a else
button_b if sequence_b else
6046 0 servo 500 delay # position of the servo when no buttons pressed
endif endif
repeat
# These subroutines each return 1 if the corresponding
# button is pressed, and return 0 otherwise.
# Currently button_a is assigned to channel 1 and
# button_b is assigned to channel 2
# These channels must be configured as Inputs in the
# Channel Settings tab.
sub button_a
1 get_position 500 less_than
return
sub button_b
2 get_position 500 less_than
return
# These subroutines each perform an arbitrary sequence
# of servo movements. You should change these to fit
# your application.
sub sequence_a
4000 0 servo 300 delay
return
sub sequence_b
8092 0 servo 300 delay
return