Hi,

1) If your opto- transistor emitter has no load to ground , no chance it works properly.

add to that you are supposed to have a HIGH level @ input when there's nothing between photodiode and and photo transistor.


2)

Code:
checkopt:
if portb.2 = 1 then
portc = runmot
else
goto checkopt
endif 
return
This is an endless loop that DOESN'T CHANGES ANYTHING !!!! if you reach required position ...

I do not think you wanted that ... ( stopping motor is doing something ... don't you think ??? so ... )

Alain