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 />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

10<br />

11<br />

12<br />

13<br />

14<br />

15<br />

16<br />

17<br />

18<br />

19<br />

void moveStraight()<br />

{<br />

if(SensorValue[leftEncoder] > SensorValue[rightEncoder])<br />

{<br />

motor[port3] = 50;<br />

motor[port2] = 63;<br />

}<br />

if(SensorValue[leftEncoder] < SensorValue[rightEncoder])<br />

{<br />

motor[port3] = 63;<br />

motor[port2] = 50;<br />

}<br />

if(SensorValue[leftEncoder] == SensorValue[rightEncoder])<br />

{<br />

motor[port3] = 63;<br />

motor[port2] = 63;<br />

}<br />

}<br />

}<br />

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

9i. Copy this code<br />

Select Edit > Copy to put the<br />

highlighted code on the clipboard.<br />

9j. Select File > Open and Compile<br />

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

9g. Open MineArmStraight<br />

Instead of re-entering the movingstraight<br />

code, we’ll take a copy of<br />

it from the Encoders program.<br />

9h. Highlight code<br />

Find the void<br />

moveStraight()<br />

function and highlight it.<br />

<strong>Ultrasonic</strong> <strong>Rangefinder</strong> • 8

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

Saved successfully!

Ooh no, something went wrong!