# is pressed it runs the corresponding sequence.
begin
button_a if sequence_a endif
button_b if sequence_b endif
button_c if sequence_c endif
repeat
# These subroutines each return 1 if the corresponding
# button is pressed, y return 0 otherwise.
# Currently button_a is assigned to channel 0,
# button_b is assigned to channel 1, and
# button_c is assigned to channel 2.
# These channels must be configured as Inputs in the
# Channel Settings tab.
sub button_a
0 get_position 500 less_than
return
sub button_b
1 get_position 500 less_than
return
sub button_c
2 get_position 500 less_than
return
# These subroutines each perform an arbitrary sequence
# of servo movements.
# your application.
sub sequence_a
4000 3 servo 1000 delay
6000 3 servo 500 delay
return
sub sequence_b
8000 4 servo 900 delay
7000 4 servo 900 delay
6000 4 servo 900 delay
return
sub sequence_c
10 4 speed
7000 4 servo 3000 delay
6000 4 servo 3000 delay
return
Tenga en cuenta que este script no hace multitarea. Si una secuencia se ejecuta, el script no detecta
otras pulsaciones hasta que la secuencia se termina. Es posible hacer que los pulsadores funcionen
de forma independiente, pero el script tendría que ser mucho más complicado.
Dependiendo de cómo trabajes con la escritura de scripts es posible que prefieras usar varios
controladores Maestro en su lugar.
Retardos largos
Los retardos largos son posibles con el comando DELAY hasta unos 32 segundos. En algunos casos
puedes necesitar retardos mucho más largos. Aquí tienes un ejemplo para muchos segundos e
minutos:
# Mover servo 0 adelante y atrás, con retardos de 10 minutes entre movimientos.
begin
4000 0 servo
10 delay_minutes
8000 0 servo
10 delay_minutes
repeat
# delay by a specified number of seconds, up to 65535 s
sub delay_seconds
begin dup while
1 minus 1000 delay # subtract one y delay 1s
repeat
drop return
# delay by a specified number of minutes, up to 65535 min
You should change these to fit
# check if the count has reached zero
# remove the 0 from the stack y return
35