Hi.
I’m creating a new topic, becouse I couldn’t find anything useful on forum.
I have a working script (Brandon M of Pololu helped me with it - thanks, which we discussed in topic 2 buttons and 3 servos) and want to upgrade it with a third button.
Push of the third button has to override any servo positions or movements immediately and send scipt cursor to end: line in the script. Im using 6 channel maestro, so third button will be on channel 0 and Im using pull down resistor on buttons.
This is the script:
6500 3 servo
6500 4 servo
6500 5 servo
wait_for_trigger_press_1000ms
goto main_loop
sub trigger
1 get_position 1023 equals
2 get_position 1023 equals
logical_and
return
sub wait_for_trigger_press_1000ms
get_ms
begin
trigger
if
get_ms over minus 1000 greater_than
if drop return endif
else
drop get_ms
endif
repeat
main_loop:
get_ms 1
begin
1 get_position 1023 equals
2 get_position 1023 equals
logical_and
if
# STRAIGHT
4000 3 servo #RUDDER
4000 4 servo #STABILIZER
4000 5 servo #WIGGLER
endif
1 get_position 1023 equals
2 get_position 512 less_than
logical_and
if
# LAUNCH
5000 3 servo #RUDDER
5000 4 servo #STABILIZER
5000 5 servo #WIGGLER
endif
1 get_position 512 less_than
2 get_position 1023 equals
logical_and
if
# CIRCLE
6000 3 servo #RUDDER
6000 4 servo #STABILIZER
6000 5 servo #WIGGLER
endif
1 get_position 512 less_than
2 get_position 512 less_than
logical_and
if
# BUNT
# RUDDER STABILIZER WIGGLER TIME (miliseconds)
4500 3 servo 4500 4 servo 4500 5 servo 0500 delay #BUNT_1
5000 3 servo 5000 4 servo 5000 5 servo 0500 delay #BUNT_2
5500 3 servo 5500 4 servo 5500 5 servo 0500 delay #BUNT_3
6000 3 servo 6000 4 servo 6000 5 servo 0500 delay #BUNT_4
# FLIGHT
# RUDDER STABILIZER WIGGLER TIME (seconds)
6500 3 servo 6500 4 servo 6500 5 servo 180 delay_seconds
end:
# DT
# RUDDER STABILIZER WIGGLER
7000 3 servo 7000 4 servo 7000 5 servo
quit
endif
dup 2 get_position 1023 equals logical_and if
drop
0
endif
dup logical_not 1 get_position 1023 equals logical_and if
drop
1
endif
dup if swap drop get_ms swap endif
swap dup get_ms minus
dup negative if
negate
endif
32000 greater_than
if
goto end
endif
swap
repeat
sub delay_seconds
begin dup while
1 minus 1000 delay
repeat
drop return