0 0
iTechBuilders

Step-by-step Guide To Building A Line Follower Robot (lfr)

  • Home
  • Projects
  • Step-by-Step Guide to Building a Line Follower Robot (LFR)
Step-by-Step Guide to Building a Line Follower Robot (LFR)

Step-by-Step Guide to Building a Line Follower Robot (LFR)

17 Nov 2026 0 Comments Blog

A comprehensive tutorial for beginners on building an Arduino-based Line Follower Robot from scratch, including chassis assembly, wiring, and code.

Step-by-Step Guide to Building a Line Follower Robot (LFR) | iTechBuilders
DIY Robotics & Embedded Systems

How to Build an Arduino Line Follower Robot (LFR): Step-by-Step Assembly Guide

A complete visual walkthrough covering chassis preparation, BO motor mounting, IR sensor alignment, wiring architecture, and track testing.

By iTechBuilders Team • Published: Nov 2026 • Hands-on Build Tutorial

A Line Follower Robot (LFR) is an autonomous mobile robot engineered to detect and follow a visual path—typically a black line on a white surface—using infrared optical sensors and closed-loop differential motor control.

Bill of Materials (Required Components)

1. Chassis Base: 2WD Acrylic Robot Chassis Sheet + 1x Caster Wheel
2. Drive System: 2x Dual-Shaft BO Motors + 2x Rubber Grip Wheels
3. Controller & Driver: Arduino Uno R3 + L298N Dual H-Bridge Motor Driver
4. Optical Sensors: 2x Digital IR Obstacle/Line Sensor Modules
5. Power Source: 2x 18650 Li-ion Cells (7.4V) + Holder + Rocker Switch
6. Interconnects: Jumper Wires (M-F, M-M), M3 Screws, Double-Sided Tape
📸 Photo 0: Complete Component Flat-Lay <img src="images/0-all-components.jpg" alt="All LFR Components">

Part 1: Mechanical Chassis & Hardware Assembly

Step 1: Acrylic Sheet (Chassis) Preparation

Mechanical Base

The acrylic base acts as the structural frame supporting all electronics, batteries, and drive assemblies.

  1. Peel Protective Film: Carefully remove the brown paper or plastic protective masking from both sides of the acrylic chassis plate.
  2. Inspect Mounting Slots: Verify the pre-cut T-slots for the BO motor clamps and the front mounting holes for the caster wheel.
  3. Mount the Caster Wheel: Attach the metal/plastic omni-directional caster wheel at the front center underside using M3 screws and brass standoffs to maintain level ground clearance.
📸 Photo 1: Clean Acrylic Sheet with Caster Wheel Mounted <img src="images/1-acrylic-sheet-caster.jpg" alt="Acrylic Chassis Preparation">

Step 2: Mounting BO Motors & Wheels

Traction Drive

Differential steering relies on two independently driven rear wheels powered by geared BO (Battery Operated) motors.

  1. Pre-Solder Motor Leads: Solder 15cm red and black wires onto the copper terminals of both BO motors before mounting. Add a drop of hot glue over the solder joints for strain relief.
  2. Secure Motor Clamps: Slide the acrylic T-clamps into the rear chassis slots and bolt both BO motors firmly in place. Ensure both shafts are aligned along the exact same axis.
  3. Press-Fit Wheels: Align the flat D-shaft of each BO motor with the wheel hub and press the rubber wheels firmly onto the shafts.
📸 Photo 2: BO Motors & Wheels Attached to Chassis <img src="images/2-bo-motors-mounted.jpg" alt="BO Motors and Wheels Mounted">

Step 3: Mounting Other Components (Arduino, Driver & Battery)

Layout & Balance

Proper weight distribution prevents wheel slip and keeps the center of gravity balanced over the drive axle.

  1. Arduino Uno: Mount the Arduino board in the center of the top deck using M3 nylon standoffs or heavy-duty double-sided foam tape.
  2. L298N Motor Driver: Position the L298N module directly behind or beside the Arduino so motor wires reach the screw terminals cleanly without tension.
  3. Battery Pack & Power Switch: Secure the 2-cell 18650 battery holder near the rear axle for better wheel traction, and mount a power switch in an easily accessible spot.
📸 Photo 3: Top-Deck Placement of Arduino, L298N Driver & Battery <img src="images/3-other-components-placed.jpg" alt="Other Components Mounted on Chassis">

Step 4: Installing & Aligning IR Sensors

Optical Array

Infrared sensors detect track contrast by emitting IR light and measuring the reflected intensity via a photodiode.

  1. Downward Orientation: Mount the Left and Right IR sensor modules facing straight down at the front edge of the acrylic chassis.
  2. Track Width Spacing: Set the center-to-center spacing between the two sensors slightly wider than your black track line (approx. 2.8 cm to 3.2 cm for a 2.5 cm tape line) so the line passes cleanly between them.
  3. Ground Clearance: Maintain a vertical gap of 1.0 cm to 1.5 cm between the IR LEDs and the floor to prevent ambient light interference.
📸 Photo 4: Front Close-Up of Downward-Facing IR Sensors <img src="images/4-ir-sensors-mounted.jpg" alt="IR Sensors Mounted on Front Bumper">

Part 2: Wiring Structure & Pinout Architecture

Keep the battery switch OFF while completing all interconnections. Ensure a shared common ground (GND) between the battery, L298N driver, and Arduino Uno.

Subsystem Source Module Pin Destination Pin Signal / Power Function
Left BO Motor Motor Wire A & B L298N OUT1 & OUT2 Left wheel drive polarity
Right BO Motor Motor Wire A & B L298N OUT3 & OUT4 Right wheel drive polarity
Motor Direction L298N IN1, IN2, IN3, IN4 Arduino Digital 8, 9, 10, 11 H-Bridge forward/reverse logic
Motor Speed (PWM) L298N ENA & ENB Arduino PWM D5 & D6 Remove jumpers; enables speed control
Left IR Sensor VCC / GND / OUT Arduino 5V / GND / D2 Left line detection digital input
Right IR Sensor VCC / GND / OUT Arduino 5V / GND / D3 Right line detection digital input
Main Power Battery (+) & (–) L298N 12V & GND 7.4V–9V primary motor supply
Logic Power L298N 5V & GND Arduino 5V & GND Regulated 5V board power + Common GND
📸 Photo 5: Complete Wiring Top-View & Circuit Schematic <img src="images/5-complete-wiring-structure.jpg" alt="Complete LFR Wiring Structure">

Part 3: Arduino Control Firmware

Upload the following C++ sketch using the Arduino IDE. Adjust motorSpeed between 90 and 160 depending on your battery charge and track curvature.

// iTechBuilders - Line Follower Robot (LFR) Firmware
#define LEFT_SENSOR 2
#define RIGHT_SENSOR 3

// L298N Motor Driver Pins
#define ENA 5
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
#define ENB 6

int motorSpeed = 130; // PWM Speed (0 - 255)

void setup() {
  pinMode(LEFT_SENSOR, INPUT);
  pinMode(RIGHT_SENSOR, INPUT);

  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);
}

void loop() {
  int leftState = digitalRead(LEFT_SENSOR);
  int rightState = digitalRead(RIGHT_SENSOR);

  // 0 = White Surface (IR Reflected), 1 = Black Line (IR Absorbed)
  if (leftState == 0 && rightState == 0) {
    moveForward();
  } 
  else if (leftState == 1 && rightState == 0) {
    turnLeft();
  } 
  else if (leftState == 0 && rightState == 1) {
    turnRight();
  } 
  else {
    stopRobot();
  }
}

void moveForward() {
  analogWrite(ENA, motorSpeed);
  analogWrite(ENB, motorSpeed);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}

void turnLeft() {
  analogWrite(ENA, motorSpeed);
  analogWrite(ENB, motorSpeed);
  digitalWrite(IN1, LOW);  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}

void turnRight() {
  analogWrite(ENA, motorSpeed);
  analogWrite(ENB, motorSpeed);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);  digitalWrite(IN4, HIGH);
}

void stopRobot() {
  digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
}

Part 4: Sensor Calibration & Track Testing

Step 5: Track Setup, Potentiometer Tuning & Live Run

Final Verification
  1. Build Test Track: Lay down a 2.5 cm wide matte black electrical tape path on a white chart paper or bright floor with smooth curves (avoid sharp 90° corners for 2-sensor builds).
  2. Calibrate IR Threshold: Power on the robot and hold the sensors over the white background. Turn the blue onboard potentiometer on each IR sensor until its signal LED turns ON. Move the sensor over the black tape—the LED must turn OFF.
  3. Execute Test Run: Center the robot straddling the black line and flip the power switch ON. Observe corner tracking and fine-tune PWM speed if overshoot occurs.
📸 Photo 6: LFR Live Testing on Black-Line Track <img src="images/6-lfr-track-testing.jpg" alt="Line Follower Robot Track Testing">

🔧 Interactive LFR Testing & Troubleshooting Helper

Select an issue observed during your test run for an instant hardware or code fix:

Comments

0
No comments yet. Be the first to comment!

Leave a Comment