- Published: Friday, 31 August 2012
- Written by majenko
Implement a "Finite State Machine."
But what actually is a "Finite State Machine"?
Put simply, a Finite State Machine (I'm bored with typing that now, let's call it an FSM - not to be confused with the Flying Spaghetti Monster, of course) is a computer program that, at any point in time, can be in one of a pre-determined number of states. A state is a specific action, such as "Waiting for button 3 to be pressed", or "Moving the servo to 69°", for example.
An FSM can replace most of your while, for and similar loops, as well as annoying functions such as delay which get in the way if you want to do more than one thing at a time.Discuss this article in the forums (1 replies).