- :-

Topics Covered

• Move Until Near Behavior

1. 1. If the robot is facing a wall, it will move untilâ€¦
2. The Distance Sensor has traveled 500 mm
The Distance Sensor is 500 mm from the wall
The robot moves 500 mm total
The robot detects an obstacle beyond 500 mm away
Mini Challenge

Mini Challenge 1: Threshold Values

The waitUntil (Distance Sensor) command uses a "Threshold" cutoff value to determine when to wait, and when to continue with the program.

 Place robot facing a wall that is more than 750mm away. Write a program that runs toward a wall, and changes the TouchLED color as gets closer: Turn the light Yellow until the sensor detects the wall closer than 750mm Then turn the light Orange until 500mm Then turn the light Red until 250mm Stop when the robot gets closer than 250mm

Can't remember how to control the TouchLEDs? Review it again from Page 3 of the Touch Sensor chapter.

Use multiple waitUntil commands in your program.

Make sure the robot is moving backwards so that it moves with its Distance Sensor facing the front.

Make sure your motor speed is low enough so the robot has time to display the different colors of the Touch LED Sensor.

Mini Challenge

Mini Challenge 2: Move Until Far

Thresholds divide Distance Sensor values into two categories:
• Distance values above (>) the Threshold are "Far"
• Distance values below (<) the Threshold are "Near"

waitUntil(Distance Sensor < threshold) waits until something is "Near" the sensor. This works well to detect a "far" away object that gets "near" because the robot moves toward it.

 Place robot facing a wall very close. Program the robot to move away from the wall until it is 300mm away.

Make sure the robot is moving forward so that it moves with the Distance Sensor facing the wall.

Did You Know?

Did you know?

How the Distance Sensor works
 The Distance Sensor uses the speed that sound waves travels to measure distance to an object! The sensor has two openings on its front; one opening emits ultrasonic waves, while the other receives them. The Ultrasonic Sensor measures distance by timing how long it takes for an ultrasonic wave sent out by the emitter to bounce off an object and come back to the receiver.