Goal: Make a floor tile black in color. When the robot enters the black tile, its speed decreases and when it comes out the tile, its speed returns back to normal.
IR sensors use Infra Red (IR) rays to emit and detect the amount of IR light that returns. Its usually used to detect between light and dark surfaces as light colored surfaces reflect more IR light than dark colored surfaces
The IR sensor block is situated in the number window as it returns a number.
Check if each sensor block is returning a value less than 50. That means its passing through a white tile. For white tiles, maintain a speed of 60 for the robot.
If the value is greater than 50, its passing through a black tile. For black tiles, reduce the speed of the robot to 30.
Complete program is shown below.
Activity: Draw a black line along the floor. Program the robot should to move along the black line.