A BIG State Machine
Now that we’ve seen how State Machines work, let’s use this structure to implement the more complicated state diagram.

- State Diagram
Remember, just like in State Machine, we can stay in a state until something happens, and that’s exactly how the Moving Forward and Moving Backward states operate. Take a look at the Moving Forward state. See how it has two Check Two sensors? It’s important to think about how to check two sensors to get one result. An easy way to do this is to use two case structures, one inside the other. This is called a Nested Case Structure.
As we saw in the previous section, this state machine utilizes reusable code. This means that code can be used for more than one part of the program. In this state diagram, we see that the Stop Motor state can be initiated from the Moving Forward and Moving Backward state. Therefore, the code is being reused. By having reusable code, we limit the amount of programming and thus save time.

PolySensor.vi
This section will introduce two new functions. The first is the PolySensor.vi. This function can become any sensor function in the NXT toolkit. All options are located in the drop down menu at the bottom of the function. This will allow you to copy one function and edit it, instead of having to go search for the function in the functions palette.
PolyWait.vi
Th last function we will learn about in this unit is the PolyWait.vi. This function is quite similiar to the Polysensor.vi, but it allows you to select any delay Wait function.