Skip to content

Robotics class project: An Arduino-based line follower optimized for speed and competition performance.

License

Notifications You must be signed in to change notification settings

altCourier/robotics-final-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Line Follower Robot: "Do it as fast as you can"

Course Project: Robotics | Date: October 2025

This repository contains the code and documentation for a high-speed line-follower robot developed as a class project. The primary goal was to implement an efficient and responsive state machine for rapid line tracking.


Contributors

This project was developed as a collaboration by the following members of the Robotics course:


Project Goal

The objective was to build a robot capable of autonomously following a black line on a white surface and completing the course as quickly as possible. This required a focus on speed and efficient state processing to minimize decision latency.


Key Features

The objective was to build a robot capable of autonomously following a black line on a white surface and completing the course as quickly as possible.

  • Speed Focus: Achieving maximum track velocity by minimizing decision latency.
  • PID Control: Utilizing a Proportional-Integral-Derivative (PID) control loop for smooth speed adjustments, reducing the "wobble" common in basic line-following robots.
  • O(1) State Encoding: The code uses bitwise operations to encode sensor inputs, ensuring $\mathbf{O(1)}$ time complexity for state lookup.

Hardware and Equipment

The robot utilizes a TCRT5000 Tracking Module for sensing the line, which is central to the control logic.

  • Microcontroller: Arduino Uno
  • Sensor: TCRT5000 Tracking Module (3-channel)
  • Actuator: DC Motors and Motor Driver (L298N is used)
  • Chassis: Robot chassis with wheels
  • Power: Battery pack (9V)

Prerequisites

To upload and run the code successfully, ensure you have the following software and libraries installed:

  • Arduino IDE: The latest version of the Arduino Integrated Development Environment.
  • Motor Driver Library (Optional): If your motor driver (e.g., L298N) requires a specific library for simplified control, ensure it's installed via the Library Manager.

Wiring and Setup

The following connections are typically required for this setup. Always verify the specific pinout of your motor driver and sensor module.

Component Function Code Definition Arduino Pin Pin Type
Line Sensor Left Sensor Input LEFT D6 Digital Input
Line Sensor Center Sensor Input CENTER D7 Digital Input
Line Sensor Right Sensor Input RIGHT D8 Digital Input
Left Motor Left Enable (Speed PWM) ENA D10 PWM Output
Left Motor Forward Direction Pin IN1 D5 Digital Output
Left Motor Backward Direction Pin IN2 D4 Digital Output
Right Motor Right Enable (Speed PWM) ENB D9 PWM Output
Right Motor Forward Direction Pin IN3 D2 Digital Output
Right Motor Backward Direction Pin IN4 D3 Digital Output

Key Wiring Notes:

  • Motor Driver Connection: The driver requires 6 control pins (IN1 through IN4, ENA, ENB). ENA and ENB must be connected to PWM capable pins (Pins D9 and D10 on the Uno) as they control motor speed via analogWrite().
  • Sensor Power: The TCRT5000 sensor module's VCC and GND pins should be connected to the Arduino's 5V and GND rails.
  • Motor Power Isolation: It is critical to power the motor driver's dedicated power input (e.g., $+12V$ or $+9V$) with a separate battery pack (not the Arduino's VIN or 5V pin). This prevents current draw spikes from resetting the Arduino.

Installation and Usage

Follow these steps to upload the code and start the robot:

  1. Clone the repository

Clone this GitHub repository to your local machine:

git clone https://github.com/your-username/line-follower-robot.git
  1. Open in Arduino IDE
  • Open the Arduino IDE.
  • Go to File > Open and navigate to the cloned folder.
  • Select the main sketch file (e.g., line_follower.ino).
  1. Configure and Upload
  • Configure Pins: Double-check that the pin assignments in the code (usually defined at the top) match your physical wiring setup.
  • Select Board: Go to Tools > Board and select your Arduino model (e.g., "Arduino Uno").
  • Select Port: Go to Tools > Port and select the correct serial port for your connected Arduino.
  • Upload: Click the Upload button (right arrow icon) to flash the code to the microcontroller.
  1. Running the robot
  • Place the robot on a designated track (a black line on a white surface).
  • Ensure the robot's main power switch (for motors) is OFF before placement.
  • Turn the robot power ON. The robot should immediately begin reading the sensors and attempt to follow the line.

Troubleshooting

In this section, I would love to talk more about the problem we have faced and you may also face during your own testing.

Robot spins in place

Check the motor direction logic in the code. You may need to swap the HIGH and LOW signals for one or both motors.

Sensor readings are off

Ensure the TCRT5000 sensor is calibrated correctly. Most modules have potentiometers to adjust the sensitivity (the threshold between detecting black and white).

Power issues

If the robot resets when the motors start, the motors are drawing too much current from the Arduino.

About

Robotics class project: An Arduino-based line follower optimized for speed and competition performance.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages