Hey can someone help here, I'm building a robot and I tried it with one whisker to see if it can go reverse if it bumped into something (leftwhisker), But my problem is that it has to stay for a while before it can go reverse in other words is that you have to hold the whisker for like 4 sec. for it to reverse. Can Anyone help me. I'm using picbasic pro demo with pic16F628 (4mhz Crystal). This is the code I used.
lefteye var portb.1 'left sensor
counter var word
sense: 'check for objects in front, right, left
if lefteye = 1 then forward
if lefteye = 0 then backward
goto sense
backward:
FOR counter = 1 TO 104 ' Backward
PULSOUT 0, 183
PULSOUT 2, 500
PAUSE 10
next
goto sense
Forward:
PULSOUT 0, 500
PULSOUT 2, 183
PAUSE 10
goto sense
end
lefteye var portb.1 'left sensor
counter var word
sense: 'check for objects in front, right, left
if lefteye = 1 then forward
if lefteye = 0 then backward
goto sense
backward:
FOR counter = 1 TO 104 ' Backward
PULSOUT 0, 183
PULSOUT 2, 500
PAUSE 10
next
goto sense
Forward:
PULSOUT 0, 500
PULSOUT 2, 183
PAUSE 10
goto sense
end