Arduino Programming – State change

How to program a state change functionality. ‘State change detection’ is a method to see when a button is pressed or released. You can use it to fire a different action each press of a button.
In this tutorial the basic code structure ( setup, loop ) of Arduino script is also explained.