Hello Readers, welcome to my Blog BloggerTipsTricks. com - A Blog For Bloggers By A Blogger. I'm Arun, an entrepreneur Blogger from India.

Line Follower Robot with ATmega16 using Analog IR Sensor

32387
Mark as Favourite

 The Line follower robot is a mobile machine that can detect and follow the line drawn on the floor. Generally, the path is predefined and can be either visible like a black line on a white surface with a high contrasted color or it can be invisible like a magnetic field. Therefore, this kind of Robot should sense the line with its Infrared Ray (IR) sensors that installed under the robot. Line follower robot is a useful robot that is used in ware houses, industries, and stores etc, where it follows a dedicated path.

In this project, we will learn How to design a line follower robot with AVR ATmega16 microcontroller using Analog IR Sensor. This robot is an automatic robot i.e no manual control is needed. The robot automatically follows a line without any deviation from the line. The robot changes its direction incase it deviates from the line. Generally, the line is of black color on white surface or white line on black surface. To detect white and black color, we will use IR sensor because white surface reflects IR rays and black surface absorbs IR rays. In this way, the output of IR sensor defers in black and white surface. In our case, we will use a black line on white surface.

Here, we will use three analog IR sensors. All the three sensors will be placed in the front side of the robot and all will be pointing downward. One sensor will be placed above the black line and the other two will be on left and right side of middle sensor. The output of the IR sensor changes when the sensors moves from white surface to black surface or from black surface to white surface and this change will be detected by the microcontroller. But the outputs of the three analog IR sensors are analog in nature, so these signals cannot be processed directly by the microcontroller. For this, we will use the ADC of the ATmega16 microcontroller to convert the analog signals to digital values. After converting the analog signals of analog IR sensors to digital values, the ATmega16 microcontroller will compare the sensor values with a reference value(3V in our case) to know the position of the sensors.

When the position of the middle IR sensor is above the black line, the ATmega16 microcontroller will send the forward control signal to the DC motor driver (L293D) of the robot to move the robot in forward direction and when the left sensor is above the black line, the ATmega16 microcontroller will send the left control signal to the DC motor driver (L293D) of the robot to move the robot in left direction and when the right sensor is above the black line, the ATmega16 microcontroller will send the right control signal to the DC motor driver (L293D) of the robot to move the robot in right direction. The above processes of ADC conversions, sensors output comparison and robot control continues. In this way, the robot follows the black line.

Softwares Required

Hardwares Required

Name / Unit Price Quantity Total Price
AVR Trainer Board-100 with ATmega16
Rs. 700.00
1pc
Rs.700.00
AVR USB Programmer
Rs. 350.00
1pc
Rs.350.00
Analog IR Sensor
Rs. 30.00
3pc
Rs.90.00
DC Motor Driver
Rs. 200.00
1pc
Rs.200.00
Robot V 4.1
Rs. 330.00
1pc
Rs.330.00
1 to 1 Connector-Female to Female
Rs. 4.00
10pc
Rs.40.00
10 to 10 FRC Female to Female Connector
Rs. 15.00
2pc
Rs.30.00
12V, 1A DC SMPS Adaptor
Rs. 130.00
1pc
Rs.130.00
TOTAL Rs.1870.00

Circuit Diagram

C Program

Fullscreen
 

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#define           REF           615
/*Defines a macro for the Reference value of the sensors*/

int main(void)
{

DDRB=0x0f;
/*PB0,PB1,PB2 and PB3 pins of PortB are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int left_sensor_value,middle_sensor_value,right_sensor_value;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

/*Start of infinite loop*/
while(1)
{

left_sensor_value=read_adc_channel(0);
/*Reading left IR sensor value*/

middle_sensor_value=read_adc_channel(1);
/*Reading middle IR sensor value*/

right_sensor_value=read_adc_channel(2);
/*Reading right IR sensor value*/

/*Checking the sensor values with the reference value*/
if(middle_sensor_value > REF)
{

PORTB=0x0a;
/*Robot will move in forward direction*/

}
else if(left_sensor_value > REF)
{

PORTB=0x02;
/*Robot will move in left direction*/

}
else if(right_sensor_value > REF)
{

PORTB=0x08;
/*Robot will move in right direction*/

}
else
{

;
/*Null statement*/

}

}

}
/*End of Program*/

  

 //**************************************************************//
//System Clock                          :1MHz
//Software                                 :AVR Studio 4
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define           F_CPU           1000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/adc.h>
/*Includes adc.h header file which defines different functions for Analog to Digital Converter. ADC header file version is 1.1*/

#define           REF           615
/*Defines a macro for the Reference value of the sensors*/

int main(void)
{

DDRB=0x0f;
/*PB0,PB1,PB2 and PB3 pins of PortB are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected )*/

int left_sensor_value,middle_sensor_value,right_sensor_value;
/*Variable declarations*/

adc_init();
/*ADC initialization*/

/*Start of infinite loop*/
while(1)
{

left_sensor_value=read_adc_channel(0);
/*Reading left IR sensor value*/

middle_sensor_value=read_adc_channel(1);
/*Reading middle IR sensor value*/

right_sensor_value=read_adc_channel(2);
/*Reading right IR sensor value*/

/*Checking the sensor values with the reference value*/
if(middle_sensor_value > REF)
{

PORTB=0x0a;
/*Robot will move in forward direction*/

}
else if(left_sensor_value > REF)
{

PORTB=0x02;
/*Robot will move in left direction*/

}
else if(right_sensor_value > REF)
{

PORTB=0x08;
/*Robot will move in right direction*/

}
else
{

;
/*Null statement*/

}

}

}
/*End of Program*/

Connection Guide

The step-by-step connection guide for Line Follower Robot with ATmega16 using Analog IR Sensor is as follows:

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 11 )

  • Connect PortB header of AVR Trainer Board-100 with Input header of DC Motor Driver with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 11 )

  • Connect the 12V pin of PWM & Motor Voltage header of DC Motor Driver with the 12V header of AVR Trainer Board-100 with a 1 to 1 Connector.

    Steps - 3 ( 0f 11 )

  • Connect the Robot connector to the Output header of the DC Motor Driver.

    Steps - 4 ( 0f 11 )

  • Switch off the Mode Switch of DC Motor Driver.

    Steps - 5 ( 0f 11 )

  • Connect the VCC and GND pins of three Analog IR Sensor with 5V and GND header pins of AVR Trainer Board-100 with 1 to 1 connectors.

    Steps - 6 ( 0f 11 )

  • Connect the O/P pins of left, front and right Analog IR Sensor with PA0, PA1 and PA2 pins of PortA header of AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 7 ( 0f 11 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 8 ( 0f 11 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

    Steps - 9 ( 0f 11 )

  • Download Line Follower Robot with ATmega16 using Analog IR Sensor Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 10 ( 0f 11 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100 and see the output.

    Steps - 11 ( 0f 11 )

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 11 )

  • Connect PortB header of AVR Trainer Board-100 with Input header of DC Motor Driver with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 11 )

  • Connect the 12V pin of PWM & Motor Voltage header of DC Motor Driver with the 12V header of AVR Trainer Board-100 with a 1 to 1 Connector.

    Steps - 3 ( 0f 11 )

  • Connect the Robot connector to the Output header of the DC Motor Driver.

    Steps - 4 ( 0f 11 )

  • Switch off the Mode Switch of DC Motor Driver.

    Steps - 5 ( 0f 11 )

  • Connect the VCC and GND pins of three Analog IR Sensor with 5V and GND header pins of AVR Trainer Board-100 with 1 to 1 connectors.

    Steps - 6 ( 0f 11 )

  • Connect the O/P pins of left, front and right Analog IR Sensor with PA0, PA1 and PA2 pins of PortA header of AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 7 ( 0f 11 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 8 ( 0f 11 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

    Steps - 9 ( 0f 11 )

  • Download Line Follower Robot with ATmega16 using Analog IR Sensor Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 10 ( 0f 11 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100 and see the output.

    Steps - 11 ( 0f 11 )

Downloads

Line Follower Robot with ATmega16 using Analog IR Sensor C File
  • 161 downloads
  • 2 Kb
Line Follower Robot with ATmega16 using Analog IR Sensor Circuit Diagram
  • 109 downloads
  • 72 Kb
Line Follower Robot with ATmega16 using Analog IR Sensor Hex File
  • 106 downloads
  • 1 Kb
ADC Header File v1.0
  • 993 downloads
  • 2 Kb

Comments