Finite State Machine Using Switch Statement.

Switch and functions will certainly help you to build a state machine. Sometimes your tests and state transitions are simple enough that they can go directly in the switch. I like to keep loop small enough (like any other function) that it can be read without scrolling though, so generally, I'll call a function that handles each state from the (then) simple switch. Here's an example I posted a while back that illustrates both:

http://arduino.cc/forum/index.php/topic,106335.0.html

Sometimes, the system is so simple that a state machine is hardly worth it, but it still makes a nice framework. Also, if functionality is added later, you don't find yourself cursing that you should have used the concept from the start. This one shows this:

http://arduino.cc/forum/index.php/topic,59511.0.html

Here's another example, pretty pure, one function to handle each state:

http://arduino.cc/forum/index.php/topic,71867.0.html.

Repeating Jack's advice, if you use this switch and function call model, the state machine practically writes itself - as long as you have specified your states and possible transitions up front.