Donnie
Check out the post of a problem I was having with code for position control of a linear actuator using reed switches as feedback. The code is all there for pulse counting , de-bounce and positioning; though make sure you check the solution to make sure you fix the problem I was having. You may find it helpful as there are some similar items covered. The difference being I am using relays for direction control vs your motor shield.
http://forum.arduino.cc/index.php?topic=236470.0
Let me know If I can help. MarkT helped me out with my problem, I am more than willing to help you out if I can.
Mike W.