Micro Maestro Help! Button, sequence, reverse sequence

Hello.

Having one button do a sequence of different things (in this case just 2 things) can usually be done easily by using some sort of state variable. Here is an example script that should function the way you described in “Situation A” once you add your servo commands where I have indicated:

1  #Sets an initial state (open)
begin

    0 get_position
    500 greater_than  #Check if button is pushed
    if
          
        dup
        if  #If helmet is open, run frame to close it

            close_helmet #Run the close_helmet subroutine
            drop  #Change the state to 0
            0

        else  #If helmet is closed, run frame to open it

            open_helmet #Run the open_helmet subroutine	            
            drop #Change the state to 1
            1

        endif

    endif

repeat


sub close_helmet #This is the subroutine to close the helmet
            #Add your servo commands to close the helmet here
    500 delay
return

sub open_helmet #This is the subroutine to open the helmet
            #Add your servo commands to open the helmet here
    500 delay
return

As for “Situation C”, you could try adding in commands in the “close_helmet” and “open_helmet” subroutines that control your LEDs. Once you get that working, you could try adding a second button that uses the “get_position” command to check the state of the LED, and changes it independently of the first button. If you have trouble with any of that, please let me know.

-Brandon

2 Likes