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.


#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

if ((LS==1) && (RS==0))        // To Move Right

if ((LS==0) && (RS==0))       // To Stop


Link 1: 

Recent Posts