New State machine tutorial

And so having belatedly noticed jbellavance's pdf (containing code, narrative and state diagrams) and having looked at it (admittedly quickly), I'm inclined to suggest it as "the" tutorial. Maybe Robin2, it's not necessary for you to do another one?