Vernier Software and Technology
Vernier Software & Technology

Changing Lanes


During this activity, students create programs that lead mBot through lane changes on a linefollowing course with two lanes. At first, lane changes are initiated by button presses on the IRRemote Control. Later, students add code to allow for automatic lane changes when obstacles or slow-moving objects are detected. For the final Challenge Extension, students program mBot to change lanes when a slower-moving object is detected and then automatically return to the original lane after 5 seconds.


  • Practice writing, running, and troubleshooting mBot code.
  • Model real-world traffic situations with mBot.

Sensors and Equipment

This experiment features the following Vernier sensors and equipment.

Option 1

Option 2

Additional Requirements

You may also need an interface and software for data collection. What do I need for data collection?

Computer Science Teachers Association (CSTA) Standards

Create clearly named variables that represent different data types and perform operations on their values.
Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
Decompose problems and subproblems into parts to facilitate design, implementation, and review of programs.
Create procedures with parameters to organize code and make it easier to reuse.
Systematically test and refine programs using a range of test cases.
Document programs in order to make them easier to follow, test, and debug.

Experiment C9 from Coding with mBot: Self-Driving Vehicles Activities Module Lab Book

<i>Coding with mBot: Self-Driving Vehicles</i> Activities Module book cover

Included in the Lab Book

Vernier lab books include word-processing files of the student instructions, essential teacher information, suggested answers, sample data and graphs, and more.

Buy the Book

Go to top