Stopping on a bumper or a distance limit

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

An EV3 robot has wheels of diameter 80 mm, drive motors on ports B (left) and C (right), and a touch sensor on input port 1 mounted on its front bumper. Positive Speed drives the robot forward. Assume direct wheel drive, so one motor revolution produces one wheel revolution, and rolling without slip. Assume the matched drive motors produce straight forward motion at equal Speed settings. Use encoder readings to estimate travel distance.


An EV3 brick connects to the left motor through port B, the right motor through port C, and the bumper touch sensor through input port 1.


Write a MATLAB script that:

  1. drives straight forward with both motors set to Speed = 35,
  2. reads and saves both the bumper condition and the encoder distance condition on each polling pass, then brakes both motors on the first pass that detects either a pressed bumper or an estimated travel distance of at least 1.2 m, and
  3. displays which condition triggered braking, giving the bumper priority if both conditions are detected on the same pass.

State the encoder target you use and show how you obtained it. A short pause between unsuccessful polling passes is recommended. Account for polling and braking delay when explaining the stopping behavior.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More LEGO Robot Programming with MATLAB Questions: