Finite State Machine Using Switch Statement.

ash901226:
the more i search and trying to understand what is Finite State Machine, the more i understand and the more i realized how much i need to know when it come to programming . however i cant help but to see the similarity between Finite State Machine with the step sequence that i use to used when programming PLC

The first job then would be getting comfortable with C/C++ then. OO coding isn't needed to do decent FSMs. Start with something simple, three or four states at most. Being able to understand the problem at hand and visualize it in terms of states can take a little practice, but usually comes pretty quickly.

Lots of examples are available, several have been offered in this thread. A lot of good FSM exercises can be done with an Arduino, some switches to represent inputs, and LEDs to represent outputs. I'll offer one more at the risk of giving you more examples than you can enjoy, it's an implementation of the common garage-door controller project that a lot of folks have done. At this point it only senses the state of the door and lights up some LEDs accordingly, and just needs two switches and some LEDs to implement. I think it has four or five states at most. Not much code, and I also have state diagrams and tables to go with.

You can think of other examples and invent your own exercises. Lots of things in everyday life can be seen as FSMs. Appliances like washing machines go through a series of states and control valves and pumps. Traffic signals and crosswalks. See Wikipedia's article for a simple FSM representing a turnstile.

I've never programmed a PLC, but yes I wouldn't be surprised if there were a lot of similarities, so you probably have some good background there in thinking about the inputs, outputs, and states that represent a system.