#=================================================================== # A simple servo sequence # The following script shows how to direct servo 0 to five different # positions in a loop. Move servo 0 to five different positions, # in a loop. #=================================================================== begin 4000 0 servo # set servo 0 to 1.00 ms 500 delay 5000 0 servo # 1.25 ms 500 delay 6000 0 servo # 1.50 ms 500 delay 7000 0 servo # 1.75 ms 500 delay 8000 0 servo # 2.00 ms 500 delay repeat #=================================================================== 10 # start with a 10 on the stack #=================================================================== begin dup # copy the number on the stack - the copy will be consumed by WHILE while # jump to the end if the count reaches 0 8000 1 servo 500 delay 4000 1 servo 500 delay 1 minus # subtract 1 from the number of times remaining repeat #=================================================================== # 3 get_position # get the value of input 3 as a number from 0 to 1023 # 512 less_than # test whether it is less than 512 -> 1 if true, 0 if false #=================================================================== if 6000 5 servo # this part is run when input3 < 512 else 7000 5 servo # this part is run when input3 >= 512 endif #=================================================================== # This example uses speed and acceleration to make a smooth # motion back and forth between 1 and 2 ms. #=================================================================== 3 0 acceleration 30 0 speed begin 4000 0 servo # set servo 0 to 1.00 ms moving_wait 8000 0 servo # 2.00 ms moving_wait repeat sub moving_wait begin get_moving_state while # wait until it is no longer moving repeat return