Documentation for building a line following robot!

This project aims to provide step by step instruction to building your first robot from scratch. This beginner friendly project has no prerequistes but will link to additional external resources for gaining a deeper understanding and taking your new skills to the next level.

The robot uses a two motor differential drive with a freely spinning caster wheel at the front of the robot. The array of infrared sensors detect reflected light to deterimine if the sensor is over a dark material (no reflection) or light material (reflection).

Image of assembled line following robot

Note

This project is under active development. More updates coming soon.

Contents

Hardware

This project is open source and a bill of materials is freely provided (below). However, if you prefer to purchase a prepared robot kit that will also financially support the development of more open source projects then you can purchase the robot here: <coming soon - insert link>

Bill of Materials

Off the shelf components

  • 1x Arduino Uno (with cable)

  • 1x L298N Motor Driver

  • 1x AA battery holder with ON/OFF switch (4 slots)

  • 4x AA batteries

  • 2x Set of TT DC motor gearbox, wheel, mounting bracket, two M3 10mm bolts, two M3 30mm bolts, and two M3 nuts (usually sold all together)

  • 1x One inch caster wheel

  • 1x Five channel TCRT5000L array

  • 13x Male-Female jumper cables

  • 2x Male-Male jumper cables

  • 15x M3 12mm bolts

  • 4x M4 20mm bolts

  • 7x M3 nuts (optional use lock-nuts or loctite)

  • 4x M4 nutes (optional use lock-nuts or loctite))

  • Extra wire for motor leads (18 AWG - 22AWG)

  • Zipties (optional for cable management)

  • Double sided tape or hot glue for securing the battery pack

Components to be fabricated See the next section for more details

  • 1x Robot body (laser cut from 3mm to 5mm wood or acrylic)

  • 1x Caster wheel spacer (3D printed)

  • 2x Infrared sensor standoffs (3D printed)

Tools

  • Soldering iron and solder

  • Computer and approatiate dongle/cable for connecting to Arduino Uno

  • Wire strippers (optional)

  • Multimeter (optional - for diagnostics)

Manufacturing

When it comes to robotics, being able to fabricate custom components is extremely valuable, however buying your own 3D printer, laser cutter, and/or CNC machine is cost probihitive to starting a journey into robotics. Fortunately these custom pieces are available for purchase from my website <insert link - coming soon>. Alternatively online 3D printing services are available, and for some, these tools may be available locally at makerspaces, public libraries, or universities at little or no cost. These components are not dimension critical so they can also be fabricated by hand out of scrap wood and a hand drill or even out of sheets of cardboard.

Robot body

The SVG file for laser cutting the body can be downloaded here. Birch wood is a great option as it is cheap and also compresses a little bit when the bolts are tightened, tereby preventing the bolts from vibrating loose. If using acrylic, it is recommended that you use lock-nuts or apply loctite to the bolts. If you do not have access to a laser cutter, you can print out the SVG file and use it as reference to cut your own robot frame out of cardboard or wood.

Caster wheel spacer

File for 3D printing available here.

Infrared sensor standoffs

File for 3D printing available here.

Assembly

Step 1 Mount the Arduino and motor driver in the orienation shown below using seven of the M3 12mm bolts and nuts

How to mount Arduino and motor driver

Step 2 Mount the motors to their brackets. Note the orienation of the motor pin orientation relative to the bracket. The image below shows the assembly for the right motor (left motor is the mirror image). Before mounting to the robot frame, solder wires to the motors to conect to the motor driver (length ~14cm).

How to install the mount the motors to the mounting brackets

Step 3 Attach the motors using M3 bolts and the caster wheel using M4 bolts. Note the 3D printed caster wheel spacer.

Install wheels on the robot frame

Step 4 Install the infrared sensor array using the 3D printed standoffs. Note the orientation of the header pins, they should face towards the front of the robot, if not they will collide with the caster wheel and make wiring more difficult.

Install the infrared sensor array using the 3D printed standoffs.

Step 5 Attach the battery pack using double sided tap or hot glue to secure in place.

Attach the battery pack to robot

Electrical

Overview

Below the overall wiring schematic is shown. Scroll further down for a step by step breakdown.

Overview of the complete wiring diagram

Infrared Sensor

In the previous hardware assembly section, the infrared sensor was attached with the header pins facing towards the front of the robot. Confirm this is correct before proceeding. Using seven male-female header pins connect the infrared sensor to the arduino anaolg pins and power pins as shown below, note that there is a slot in the robots frame to pass the wires through. Ensure the power cables (GND and 5V) are crossed over as shown in the picture below.

Electrical connections to the infrared sensor array.

Motors

Connect the motors the the L298N motor driver screw terminals using the wires that were soldered to the TT motor gearbox in the hardware assembly section. Use 4 male-female jumper cables to conenct the L298N motor driver to Arduino digital pins 5, 6, 10, and 11. Finally, confirm the three header pin jumpers are installed on the ENA, ENB, and 5V EN pins (as comes stock). More information on the L298N motor driver and header pins available here.

Connections between the motors and L298N motor drivers

Power

To power the robot we will use 4 AA batteries in series giving a voltage of 6V. Make the connections below, note that the black ground wire from the battery is spliced (and ideally soldered) to a second black wire that connects to the GND pin of the Arduino. The red wire coming out of the L298N 5V terminal will power the Arduino. However we already occupied the 5V pin in the infrared sensor electrical connection. Thus instead we will connect this red 5V wire to the IOREF pin, which it the input/output reference voltage pin that connects to the Arduino logic voltage which just so happens to be 5V.

Connections to provide power to the robot

Note

The L298N motor driver is incredibly inefficient (hence the large metal hink sink) and drops about 2V, meaning the motors are only getting around 4V. This is okay since the TT motors are rated for 3V - 6V, but if you want more power you could use a battery with a higher voltage such as a 7.4V lipo. While the L298N motor driver is inefficient it was chosen for this project as it is cheap, widely available, and there are plently of great online tutorials for beginners. I would recommend using this motor driver for most beginner projects and then switching to something like the slighty more expensive Cytron MDD10A motor driver down the line.

Arduino Overview

Note

This project is under active development. More updates coming soon.

When documentation is complete this page will serve as a beginner friendly intro into programming with Arduino. In the meantime please refer to the official Arduino resources.

Physical Board

Programming

Sensors and Actuators

Note

This project is under active development. More updates coming soon.

When documentation is complete this page will provide detailed steps and explanation of the code. In the meantime the source code is available for reference here.

Bang-Bang Algorithm

Note

This project is under active development. More updates coming soon.

When documentation is complete this page will provide detailed steps and explanation of the code. In the meantime the source code is available for reference here.

Advanced (PID) Algorithm

Note

This project is under active development. More updates coming soon.

When documentation is complete this page will provide detailed steps and explanation of the code. In the meantime the source code is available for reference here.

Debugging, Troubleshooting, and Resources

Note

This project is under active development. More updates coming soon.