Arduino Line Follower Remote Control Car With Object Detection

by elbales in Circuits > Arduino

555 Views, 2 Favorites, 0 Comments

Arduino Line Follower Remote Control Car With Object Detection

Screen Shot 2024-03-07 at 6.10.36 PM.png

The goal of this project is to create a multi-functional Arduino car powered via battery. This car has several operating modes, including basic user-guided driving (via IR remote), object detection via ultrasonic distance sensor, and a line following mode using line detection sensors. Upon completion of this project, the user will have the freedom to operate their car manually or simply allow it to wander autonomously.

Supplies

Breadboard 

Arduino Uno 

Sparkfun Line Sensors (MFN: SEN-11769) (Quantity – 2) 

Adafruit Ultrasonic Distance Sensor (3942) 

Sparkfun Motor Driver (TB6612FNG) 

Adafruit AA 4-Battery Pack w/ Arduino Connector (3859) 

AA Batteries (Quantity – 4) 

Sparkfun Gear Motors (ROB-13302) (Quantity – 2) 

Sparkfun Gear Motor Wheels (ROB-13259) (Quantity - 4) 

3D Printed Chassis Parts – Main Body, Rear Axle 

Arduino IR Remote and sensor breakout board (https://a.co/d/0l24jXJ) 

Arduino Code + Wiring Diagram

Screen Shot 2024-03-07 at 2.28.06 PM.png

The circuit(s) for all components are wired as shown. Note that the motor controller shown in the schematic is a generic H-bridge chip, not the Sparkfun motor controller board. More information for wiring this breakout board can be found on the Sparkfun website. In this schematic, pins 6-13 are used as digital I/O and analog pins A0-A2 are used to read the various sensors. The 5V battery pack that powers the arduino is not shown.

Assembly + Code Upload

Screen Shot 2024-03-07 at 2.29.43 PM.png
Screen Shot 2024-03-07 at 2.30.04 PM.png
Screen Shot 2024-03-07 at 2.30.19 PM.png
Screen Shot 2024-03-07 at 2.30.29 PM.png
Screen Shot 2024-03-07 at 2.30.37 PM.png
Screen Shot 2024-03-07 at 2.44.11 PM.png
Screen Shot 2024-03-07 at 2.31.00 PM.png
Screen Shot 2024-03-07 at 2.31.32 PM.png
Screen Shot 2024-03-07 at 2.31.44 PM.png
Screen Shot 2024-03-07 at 2.31.54 PM.png
Screen Shot 2024-03-07 at 2.32.59 PM.png

The assembly for this vehicle is straightforward, as the chassis only involves two components: the main body and the non-drive wheels’ axle. All components are hot glued or press fit onto their respective parts in the locations shown in figures 5-14.

In figure two, the 3D printed main body of the chassis already has all the necessary mounting locations for the line sensors and the non-driven wheels’ axle. The line sensor “nubs” ensure that the sensors sit as close to the ground as possible for accurate line reading.

Upon completion of steps 5-14, your final vehicle should look something like this. Ensure that the line sensors are low enough to the ground to easily detect a black line on a white surface (you can test this with a marker on a piece of paper). The ultrasonic distance sensor should be mounted as perpendicular to the main body of the chassis as possible for accurate distance readings. For the IR sensor, the placement is not directionally sensitive, simply make sure it doesn’t become too tangled up with the wiring.

How to Use

As mentioned in the introduction, this car has three modes of operation: user-input driving mode, object detection and avoidance mode, and line following mode. Simply set your mode on the IR remote by pressing [??]. For the line following mode, the Arduino must be placed so that the line starts on or in between its sensors, or it won’t be able to start following it. Sharp turns will also throw it off, so some user input may be needed to get it started.   

Working Video