To create a State Machine, first go to the Gadgets tab on the Palette, then go to Other Chips > Next Page, and select the State Machine chip. To create a State, either create a State chip from the Palette, or Select your State Machine, open the Context menu [...], and select "Add State". Note that your first State will need to be Connected to your State Machine chip, as this is how you define your default state. States created from the Context menu will automatically be connected.
Things to know
- The current State in a State Machine is indicated by which State is lit up on the front.
- States will automatically attempt to transition to the next State.
- By configuring a State with the Configure tool, you can change what three values the State Machine Chip will output when it is in that State, the minimum time spent in that State before automatically transitioning to the next, and the name of the State.
- States need to be wired together in the order that you need them to move in. i.e. a State Machine for a door would transition from Closed > Opening > Open > Closing > back to closed.
- You can specify when one State will transition to the next with a Circuit input, by connecting to the arrows that appear on State connection lines.
- State Machines need to be wired in a manner such that they will always return to the default state.
- Only one state can be active per State Machine at any time.
- There are three output pins on States. These are similar to the Output pins on Trigger Zone and Buttons, in that the Red pin will output tick a 1 when transitioning into the State, the Green pin will output a when while in the State, and the Blue pin will tick a 1 when transitioning out of the State.
- There are two input pins on a State Machine. The Red pin will allow you to turn the State Machine on and off, and the Reset pin will reset the State Machine back to its default state.
- The five output pins on a State Machine chip will output Value 1, 2 and 3 of the current State (on Red, Green, and Blue respectively), the Cyan pin will output the how long the current state has been active (in milliseconds), and Magenta pin will send a 1 for one tick when a State Transition occurs.