You can easily animate the behavior defined with a statechart. Please study the following demo model to get the idea (the required code is specified in the dynamic properties of rectangles).
Demo model: Elevator Doors Animation-
How can we improve this article?
-