Project tutorial
Simple Line Follower Robot

Simple Line Follower Robot © CC BY-NC-SA

Simple line following robot using IR proximity sensors, Arduino UNO and motorsheild.

  • 5,230 views
  • 0 comments
  • 10 respects

Components and supplies

Apps and online services

About this project

Hey, Today I'm going to share information about a simple robot made using Arduino UNO, motorshield and some basic components.This project is easy to make and helps in learning about basic robotics and programming.hope you like it and learn something from it.

What Is an Autonomous Robot?

An autonomous robot is simply a machine which is programmed once and then performs tasks on its own.Basic examples of autonomous robots are, 1. Obstacle Avoidance.2. Line Follower.

In this Instructable we are going to learn about a simple Line Following Robot which uses Infrared sensors to detect Black line on White surface.

These sensors can be bought online for cheap or you can make them yourself which is even better as it is fun and educational.

I have posted a tutorial about how to make these sensors, you can check it out : IR Proximity Sensor

Now as you know what the project is, We can move ahead to start building.

Building the Chassis:-

First you need to cut the wood into two pieces. 1st one is about 12cm x 10cm. 2nd one is about 10cm x 7cm.

The larger piece is the base where motors will be attached and batteries will be kept.

The smaller piece will be used to mount the Arduino and will be placed on top.

Once you have the two pieces according to the measurements, first drill holes in the larger board to attach the angle brackets for motors. Refer to the picture.

Next connect the motors to the brackets and screw them in place.

Now attach the wheels to them and secure them using some screws.

Now flip the board upside down and stick the caster wheel, you can drill a hole and connect it using screw but then the screw makes a bump in the front which doesn't look very good.

with this the lower base is done and now we make the upper base to mount the Arduino. For this first place the Arduino on the board and mark the screw holes with a marker. and drill through them. Now screw down the Arduino in place.

Now we have to connect the motorshild to the Arduino but before that we have to solder some pins to the shield. If you look at the bottom right corner you will see some holes which are the Analog pins next to them is the ground rail and next to it is the +5v rail, solder header pins to all this holes as we will need to connect sensors.

After the soldering is done, we can connect the motorshild on top of Arduino.

Next we will take some double sided tape and stick it to the bottom of this board and place it on top of the motors, to prevent it from falling we can add some spacers in front as I have shown In the Picture. Here I have used paper to make spacers as I couldn't find normal ones. I rolled paper and used superglue to make it solid hard.

If you are too lazy to build a chassis you can buy one online (2WD Robot platform) but whats the fun in that??

With this The basic body structure is done and we can move on to the Next part.

Building Power Supply Unit :-

Now once the base is done, we can move on to start making the power unit. To power our robot we will be using two 9v batteries and use a DBDT switch to turn the circuit on. Follow the diagram and attach male header pins to one side of the wires or you can leave it as it is. These wires are going to power the motorshield. Solder a DC power jack to the other two terminals for the Arduino.

NOTE:- As here we are using two separate batteries to power the Arduino and Motorshield, we will have to remove the jumper from the Motorshield which is next to the power terminal of the Shield on right side.(Refer the image above)

If you don't do it there is chance that you may damage the Microcontroller. Refer to the image above to find out the jumper.

Okay so once we have a power supply unit ready we have to connect the pins to the motorshield and Jack to the Arduino. (Make sure that you don't plug in the batteries right now, Cause nothing will work anyway.) connect the red (+ve terminal) to the left side of power terminals of motorshield and the Black(-ve terminal) to the right side.

Now find a place around the robot to place the switch, I have placed it behind, near the motors. Just keep it where it is easily accessible.

Connecting Sensors :-

Now we will add sensors to our robot, so it can scan the for the black lines. These Infrared sensors I've used have 3 Pins,

1. VCC which is the +be terminal and should be connect to the +5v.

2. GND which is the -ve terminal and must be connected to the ground.

3. Signal pin. which is connected to any Analog pin on Arduino.

here we are using 2 sensors so we will need 2 Analog pins, A4, A5.

Just connect the pins to the Motorshield and place the sensors in front, one left, one right.

Use a small cardboard piece to mount sensors on.

Connect the sensor's VCC pin to +5v and GND to GND pin on motor shield.

Connect the Out pin of right sensor to A4 and left sensor to A5.

With this the Robot is ready, it just needs a program to run and perform its task of avoiding obstacles.

Programming and Testing :-

To program the robot first connect the USB cable of arduino to the port as shown in the picture.

For those who are new to arduino you first have to download the Arduino IDE. then you can upload the code.

Once the code is uploaded the robot is ready to start the action you can now connect the 9v batteries and test.

For the track use an electric tape that is black and stick it in a circle on a White surface. Now place the robot on the line and switch it On. the bot should start to follow the line if it does not follow the line then you may have to adjust the pot on the module just slowly turn it one side until it turns on then turn it the other side until it is off now it now it should turn on when on white and off when on black this means the robot is ready to go.

Hope this tutorial was informative and helpful.If you have any questions fill free to ask in the comments.

Thank you

Code

LineFollowing RobotArduino
Check Serial monitor for debugging.
#include<AFMotor.h>

AF_DCMotor motor1(2,MOTOR12_1KHZ); //Motors
AF_DCMotor motor2(3, MOTOR12_1KHZ);

int sensorPin1 = A4; //LDR 
int sensorPin2 = A5;



void setup() 

 {
  
  Serial.begin(9600);   // Start Serial & set pin to output  
  Serial.println("Motor test!");
  motor1.setSpeed(250); 
  motor2.setSpeed (250);
  
  }

void loop() 

{
  int sensorValue1 = analogRead(sensorPin1);// Read the sensor pin
  int sensorValue2 = analogRead(sensorPin2);
 
  
  //if light intensity it High 
  if (sensorValue1 > 50)
  {
  Serial.println("Turn Right");
  motor1.run(FORWARD);
  }
  else
  {
    motor1.run(RELEASE);
  }
   
  if (sensorValue2 > 50)
  {
  Serial.println("Turn Left");
  motor2.run(FORWARD);
  }
  else
  {
    motor2.run(RELEASE);
  }
}

Comments

Similar projects you might like

Simple Line Follower Robot with PCB Design

Project tutorial by Jithin Sanal

  • 1,665 views
  • 0 comments
  • 7 respects

Line Follower Robot

Project tutorial by Shubham Shinganapure

  • 7,759 views
  • 3 comments
  • 19 respects

ARMin v2: Simple Robot Car and Arm Controller Using Python

Project tutorial by HyperChiicken

  • 1,913 views
  • 0 comments
  • 7 respects

PID Control Line Follower Robot

Project tutorial by Team KittenBot

  • 28,204 views
  • 5 comments
  • 36 respects

Amazing 6WD Off-Road Robot | Arduino RC Robot

Project tutorial by Jithin Sanal

  • 9,980 views
  • 0 comments
  • 54 respects

Simple Gesture Controlled Robot Using Arduino

Project tutorial by Jithin Sanal

  • 7,183 views
  • 1 comment
  • 28 respects
Add projectSign up / Login