Programming the true case

What happens if the US sensor does detect an obstacle within 20 centimeters? This means that a collision is imminent and the EV3 must make a decision: attempt to climb over the obstacle or steer to avoid it.

The autonomous program decides which action to take based off of the reading on the IR sensor, which is in the high position. If the IR sensor also detects the obstacle, the robot knows the obstacle is too high to climb, and it must steer to avoid it. However, if the upper sensor does not see the obstacle, the robot knows that the obstacle is low enough and it will attempt to climb it:

We program this decision using another switch, this time using the IR sensor in port 4. The switch's mode should be set to Infrared Sensor | Compare | Proximity. As you can likely guess, this makes use of the IR sensor's proximity functionality (the Security Tank used the beacon tracking function, and the RC program we just made uses its functionality as an infrared receiver).

Verify that port 4 is selected. Then, set the threshold value to less than 35 centimeters (< | 35). This value is slightly larger than the US sensor's threshold value of 20 centimeters because the IR sensor is mounted farther back on the robot than the US sensor.

When you finish setting up your IR sensor switch, it will look like this:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.202.167