03.03.2013 Views

Ultrasonic Rangefinder Forward till Near - ROBOTC.net

Ultrasonic Rangefinder Forward till Near - ROBOTC.net

Ultrasonic Rangefinder Forward till Near - ROBOTC.net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sensing<br />

<strong>Ultrasonic</strong> <strong>Rangefinder</strong> <strong>Forward</strong> <strong>till</strong> <strong>Near</strong> (cont.)<br />

7. Choose the (condition) based on the <strong>Ultrasonic</strong> <strong>Rangefinder</strong>. The (condition)<br />

should make the movement commands repeat as long as the distance to the<br />

target is s<strong>till</strong> above the desired value.<br />

Auto<br />

Auto<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

10<br />

11<br />

const tSensors sonarSensor = (tSensors) in5;<br />

task main()<br />

{<br />

wait1Msec(2000);<br />

bMotorReflected[port2] = 1;<br />

while(SensorValue[sonarSensor] > 3)<br />

{<br />

motor[port3] = 63;<br />

motor[port2] = 63;<br />

}<br />

}<br />

8. Download and Run.<br />

Checkpoint<br />

© Carnegie Mellon Robotics Academy / For use with VEX ® Robotics Systems<br />

8. Go to Compile and Download Program<br />

7. Add this code<br />

The (condition) should be true as long<br />

as the <strong>Rangefinder</strong>’s value is above 3<br />

inches. This will make the robot move<br />

forward as long as the <strong>Rangefinder</strong> does<br />

not detect any objects within 3 inches.<br />

Your robot will run forward until it is within 3 inches of a detectable object. Not all objects are<br />

detectable, however, and the “area” of detection is only in front of the <strong>Ultrasonic</strong> <strong>Rangefinder</strong><br />

itself. These limitations are inherent to the technology, but the sensor does seem to be able to<br />

detect the mines, as we had hoped.<br />

<strong>ROBOTC</strong><br />

<strong>Ultrasonic</strong> <strong>Rangefinder</strong> • 6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!