steppermotor only few steps

The StateChangeDetection I found on the pages of Arduino but I can't figure it out how to do it!

Look carefully at what the program does. It reads the current state of a pin and compares it with the state it read the previous time. If they are not the same then the pin has changed state which means that the switch connected to it has become closed or become open. By looking at the current state it is possible to determine whether it opened or closed.