Attention: Safety Recall of Vernier Go Direct Charge Station. Click to learn more.



Changing Lanes

Experiment #C9 from Coding with mBot: Self-Driving Vehicles


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 sensors and equipment. Additional equipment may be required.

Ready to Experiment?

Ask an Expert

Get answers to your questions about how to teach this experiment with our support team.

Purchase the Lab Book

This experiment is #C9 of Coding with mBot: Self-Driving Vehicles. The experiment in the book includes student instructions as well as instructor information for set up, helpful hints, and sample graphs and data.

Learn More