Skip to main content

Line Follower

A robot that follows a black line on a white background.

info

Author: Istudor Victor Mihai
GitHub Project Link: https://github.com/UPB-FILS-MA/project-istudormihai

Description

This robot will be capable of following a trajectory given by a black line on a white background, with the help of two infrared sensors placed in the front. The robot will be powered by a 9V battery that will give current to 4 DC motors connected to a L298N motor driver.

Motivation

I chose this project because i started to have a passion for robotics. Being a member of the robotics club within the FILS faculty, i had to build a similar robot for the PoliFest event, but it used an Arduino UNO and the coding part was fairly simple, as it was written in C. As soon as i saw the project rules, i thought that i can give myself a bit of a challenge by building the same robot, but in this case using a Raspberry Pi Pico, having its software written in Rust.

Architecture

Robot Architecture

Instructions

Compiling: cargo build --release --target thumbv6m-none-eabi

Log

Week 6 - 12 May

  • My parts order arrived and i started to think about the way i can build this robot.
  • Looked up on the internet for some Rust libraries that could help me write the software.

Week 7 - 19 May

  • Finished the KiCad schematic and built the robot.
  • Started working on the software.

Week 20 - 26 May

  • As i was working on the software, i realised that the sensors are sending analog values and i have to convert them to digital values, so i moved the sensors from pins GP2 and GP3 to pins GP26 and GP27 (respectively ADC0 and ADC1). As the EN_A and EN_B pins on the L298N are used for enabling and controlling the speed of the motor, i set them as PWM pins. This also meant that i did not have to use additional crates for the L298N or the DC motors.
  • Worked on the functions for the motors and the logic that the robot will have to use.
  • Finished the software.
  • Created a track that the robot will have to follow.
  • Updated the documentation.

Hardware

The "brain" of this robot will be the Raspberry Pi Pico microcontroller. The IR sensors and motor driver will be connected to it. The battery will be able to power the motor driver and the Pico. All 4 of the 3V-6V DC motors will be hooked-up to the H-bridge.

These are the components that i will use:

Components

Soldering:

Solder

The final product!

Robot

I added some stickers.

Stickers1

Stickers2

Schematics

Schematic

Bill of Materials

DeviceUsagePrice
Rapspberry Pi Pico WThe microcontroller35 RON
2x IR Sensor ModuleUsed for line detection8,78 RON
4x DC MotorsMotors19,28 RON
L298N Dual H BridgeThe motor driver11,49 RON
Female to female jumper wiresWires11,07 RON
Male to female jumper wiresWires5,18 RON
Jumper setWires8,68 RON
Breadboard-3,35 RON
4x Rubber WheelsWheels42.84 RON

Software

LibraryDescriptionUsage
embassyFrameworkUsed for building embedded applications in Rust
gpioGeneral-purpose Input/Output (GPIO) moduleUsed to control GPIO pins
ADCAnalog-to-digial converter moduleUsed to control ADC pins
  1. Principle Operation of a Line Follower Robot.
  2. How IR sensors work.
  3. How the L298N motor driver works.
  4. IR Sensor Module Circuit.