Robotics – Simple Line Follower

The program controls a spike prime robot equipped with two movement motors (C and D) to follow a black line on a white surface. It uses a light sensor (B) to detect the line and adjusts the robot's movement accordingly

Initialization:

  • Waits for 2 seconds when the program starts.
  • Sets both movement motors (C and D) to operate.
  • Sets the movement speed to 30%.

Line Following Loop:

  • Moves the robot forward for 1 rotation.
  • Resets a timer.
  • Repeats the following until the timer exceeds 3 seconds:
    • Checks the light sensor reading (B reflection):
      • If the reflection is greater than or equal to 75%, it means the robot is on the white surface (off the line). In this case, it starts moving left at a speed of -30.
      • Otherwise, it assumes the robot is on the black line and starts moving right at a speed of 30.

Stopping:

  • After the timer exceeds 3 seconds, the robot stops moving

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top