line follower & ping sensor
So i have my line follower code all worked out, Im trying to add the ping sensor for collision detection. In my code i have Im not sure where to put the code to check the distance for the sensor and to send the motor stop pulses. On that note, im not even sure if I wrote the code for checking and the if statement to stop the motors correctly. Anyways, I attached a copy of the code, can anyone look it over and tell me what im doing wrong.
I think its because while the program is looping its looping from "select qtis" untill "endselect" im thinking i need to add the code to check the ping, and also the if statement inside that main loop, but i have no idea where to put it.
I think its because while the program is looping its looping from "select qtis" untill "endselect" im thinking i need to add the code to check the ping, and also the if statement inside that main loop, but i have no idea where to put it.
DO
GOSUB Check_Qtis
' PULSOUT Ping_Pin, 5 ' Send short pulse to Ping
' PULSIN Ping_Pin, 1, time ' Wait for echo
' inDistance = inConstant ** time ' Convert to inches
' IF (inDistance < 6) THEN
' PAUSE 5
' PULSOUT HB25, 750
' PAUSE 1
' PULSOUT HB25, 750
' ENDIF
SELECT qtis
CASE %1000
PAUSE 5
PULSOUT HB25, 750
PAUSE 1
PULSOUT HB25, 695
CASE %1100
PAUSE 5
PULSOUT HB25, 750
PAUSE 1
PULSOUT HB25, 695
CASE %1110
PULSOUT HB25, 625
PAUSE 1
PULSOUT HB25, 625
CASE %0100
PAUSE 5
PULSOUT HB25, 750
PAUSE 1
PULSOUT HB25, 695
CASE %0110
PAUSE 5
PULSOUT HB25, 805
PAUSE 1
PULSOUT HB25, 685
CASE %0010
PAUSE 5
PULSOUT HB25, 805
PAUSE 1
PULSOUT HB25, 750
CASE %0001
PAUSE 5
PULSOUT HB25, 805
PAUSE 1
PULSOUT HB25, 750
CASE %0011
PAUSE 5
PULSOUT HB25, 805
PAUSE 1
PULSOUT HB25, 750
CASE %0111
PULSOUT HB25, 875
PAUSE 1
PULSOUT HB25, 875
CASE ELSE
ENDSELECT
LOOP
Check_Qtis:
DIRB = %1111
PAUSE 0
DIRB = %0000
PAUSE 0
qtis = INB
RETURN
