Calculating Speed with Two Sensors

Your state machine makes alot of since and I am giving it shot but as always in programming something will go wrong. We have a pulldown resistor from the digital output to GND but not on the analog so the pins aren't floating I believe. Thanks for the help I will update hopefully if something works or needs tweaking.