Micromelon Robotics
Platform
Resources
NewsAbout UsDownload
Support
Build Your Kit

Stay in the loop

New activities, teaching guides, and product updates delivered to your inbox.

Micromelon Robotics

Australian-made educational robotics for the next generation of innovators.

contact@micromelon.com.au

Company

  • About Us
  • Privacy Policy
  • Terms and Conditions

Products

  • Micromelon Rover
  • Code Editor
  • Robot Simulator
  • Junior
  • Python Library

Support

  • Resources
  • News
  • Rover Repairs
  • Contact
  • Build Your Kit

© 2026 Micromelon Robotics Pty Ltd. All rights reserved.

ABN 56 623 302 296

← Back to Resources
ActivitiesAdvanced

Activity: Lane Guidance

Coding Skills

BranchingIterationAlgorithm DesignMaths

Rover Concepts

UltrasonicIRMotors
Activity: Lane Guidance

Program Rovers to stay in the middle of a lane marked out by walls, a simplification of the lane-assist technology in cars. Use the front ultrasonic sensor and both IR sensors to determine where the walls are and drive as smoothly through the middle of the path as you can. Don’t run into the walls!

Activity Demonstration: Lane Guidance

Setup

Create a curving walled passage on the floor. The walls can be anything from books to wooden blocks, as long as they’re solid and tall enough to be detected by the IR and ultrasonic sensors. Tight passages and sharp corners greatly increase the difficulty. You can also add coloured tape as traffic markers that the Rover must stop at or turn around at.

Our Approach

The core of this problem is: if the wall on the left is closer than the wall on the right, you need to turn right. This can be done with IF statements, get that working first before looking at this solution. Once you’re confident, check out the PID example to make it smoother.

Stage 1: Read the Sensors

Using clear variable names makes code easier to read and follow. We use variables to calculate the difference between the distances read by the two IR distance sensors.

Stage 2: Calculate Motor Speeds

The Scale Number math block converts a number from one range to another. We used −35 to 35 because that suited the width of our passage, about the maximum difference possible between the left and right distance sensor readings. We converted that to −7 to 7 so the maximum difference between the motor speeds is 14 cm/s.

The left and right motor speeds are then calculated by adding or subtracting this value from a base forward speed, so the Rover always moves forward.

Example code, IR-based lane centring

Example code, IR-based lane centring

Once your Rover is navigating the lane smoothly, try narrowing the passage or adding sharper turns. You can also experiment with a full PID controller to get even smoother movement through the course.

Continue Learning

Activity: Line FollowingRelated resourceActivity: Line FollowingLearn the colour sensor and simple algorithm design while following a line.

Getting Started With Proportional ControlRelated resourceGetting Started With Proportional ControlAn introduction to proportional control, what control systems are, the key components, and how to apply proportional control on the Micromelon Rover.

← Return to Resources