How To Make A Line Follower With ATmega8 or ATmega16

post footer border
Line follower is a bot who detect the black line strip and follow(s) that path.

Some of the people think it is very hard to code and develop a Line Follower bot, but in reality it is super easy to make.

It just looks complicated but it's not.

You just need to have some knowledge of C language and some tools.

So, to make a Line follower you must have the following
- 2 servo motors
- 2 IR sensors
- ATmega 8 or ATmega 16 development board
- A 9 volts Battery

Here we using an ATmega8 Dev v1.0.

Here we connect the servo motors to the PORT B of microcontroller and IR Sensors to the PORT C of microcontroller.

NOTE :- Channel B [ PORT B ] is of 8 bit and channel C [PORT C] is of 7 bit.

AVR STUDIO CODE

#include <avr/io.h>
void main ()
{
while (1)
{
int LS,RS;             // Left and Right IR Sensor
LS = PINC&0B0000001;    // connected to channel c [PORT C] 
RS = PINC&0B0000010;

if ((LS==1) && (RS==2))          // To Move Forword
{
PORTB=0b00001001;             // Motor is connected to PORT B 
}

if ((RS==2) && (LS==0 ))        // To Move Left
{
PORTB=0b00000001;
}

if ((LS==1) && (RS==0))        // To Move Right
{
PORTB=0b00001000;
}

if ((LS==0) && (RS==0))       // To Stop
{
PORTB=0b00000000;
}
}
}


DOWNLOAD FULL PROJECT FILE HERE

Link 1: 
LineFollower-turbobit


Recent Posts