Because the <=6 test uses absolute value there is a very tiny range .0588v wide where the test will pass.
This is what I forgot before when I did that quick min/max calculation (and I forgot to note that it was absolute value).
Specifically, from the raw sensor readings:
- 0v to 0.6761v fails the test
- 0.6762 to 0.735 passes the test
- 0.736 to 5.0v fails the test
I couldn't get my sensor to hit that tiny range last night and trigger a 0 speed.
I'd suggest positioning your sensor at the min and max of where you want the robot to be, take the sensor readings at both positions, and I wouldn't test for being between those two raw sensor marks. I'd just test for being less than the first one. The way it's setup now, if the robot doesn't stop within the 6" it overshoots the mark and drives away.