Help writeing animatronic code

im doing an animatroc iron man helmet im using the 6 channel mini maestro servo controller and I need to do a code where I push a button and runs frame 1(open helmet) and when I push it again it runs frames 2-9 (closed with a flickering light affect) and a course I push it again it runs frame 1 like this video here

please and thank you

Hello.

One way to have a single button control different tasks, like opening and closing your Iron Man helmet, is to use some sort of state variable. With the Maestro, this means using the stack to hold your state when you are not checking it. An example script showing how to do this can be found in this similar thread. It might be easiest for you to use this script as a starting point and add to it until you get it to do what you want. If you try this and have problems, you can post your script here, and I would be glad to help.

-Brandon