The type of programs we are talking about here are reactive programs. They are programs that react to events with apropriate responses.
The conceptually simplest way to make a program react to an expected event, say an input turning on,
is to have it sit in a program loop waiting for the event to happen. We call this a wait loop.
In an old fashioned flow chart format the wait loop is drawn as shown in
figure 1
.
You read this little diagram as "The program will get to this point. Then it will sit and wait until the input comes on, then it will continue".
Note: Figure 1 is not a state diagram. It is a snippet of an older form of diagram called a flow chart. I am starting with that because a lot of people already know flowcharts.