I second this
Here is a small introduction to the topic: Yet another Finite State Machine introduction