We are trying to program a banner sensor interrupt in C. There are three possible positions(numbered 1, 2 &3) for the banner sensor to see and two directions that it can travel (forward and reverse). We have no problem with the sensor seeing the targets. Our problem comes when we stop between target 1 & 2 or between target 2 & 3 and then reverse direction. The program seems to get confused as to where it is and what the count is so that if it stops between target 2 & 3and reverses direction it thinks it sees target number 3 when it is actually seeing target number 2.
I am certain we are missing something simple. Can anyone help??