Sei sulla pagina 1di 7


The purpose of this robot is to keep moving on a platform without

falling from it. For this it detects the edge of the platform and avoid
the edge by turning to opposite side for example if it detects an edge
to its right, it turns to left and vice versa.


Edge Detector Robot

Hardware components required and their purpose:

1. A microcontroller (ATMega8)
2. IR Sensor
3. Comparator
4. DC motor
5. Motor driver IC (L293D)
6. Wheels
7. Power adopter
Microcontroller (ATMega8): This is the brain of this robot in
which the program is loaded to do the required functioning and
is interfaced with sensors and the motor driver to make the
system work as required.

IR sensor: This senses whether there is platform in front of the

robot or an edge is arrived and sends the appropriate signal to
the comparator.

Comparator: This gets input from the sensor, compare it with

predefined voltage and send logic 1 to microcontroller if there is
detected a still platform and logic 0 if edge of platform is there.

IR Sensor Circuit

DC Motor: This motor is controlled with DC voltages and can

move in forward and backward direction according to the
polarity of the voltage applied.
Motor driver IC (L293D): Microcontrollers cant supply the
current required by DC motor to run. So, to fulfill this
requirement these motor driver ICs are used.

DC motors with Driver IC

Power adopter: This is used to give appropriate dc power

supply to microcontroller, driver IC sensors and the other
passive components of the robot.

Wheels: In it three wheels are employed, two at rear end and one
at front end. Rear wheels are attached with the motors and also
control the steering of robot. Front wheel is the loose steered
wheel which moves in the direction of the pressure applied to it.

Block Diagram:

Block Diagram: Edge Detector

The sensors are mounted at front end of the robot at both left and
right side. The sensors are designed to detect the light reflecting from
the platform on which it is moving and at the edge, sensors dont get
this light. The robot starts moving on platform and until it is on the
platform it is receiving the reflected light and robot keeps moving. As
soon as it reaches the edge (say left edge), the left sensor doesnt

receives the light and the comparator sends logic 0 to the

microcontroller for the left sensor. On getting this condition the
microcontroller make the robot to turn right by turning only the left
motor ON and making the right side motor OFF. Reverse will happen
if the right sensor detects the edge.
In this way the robot keeps moving on the platform and doesnt fall
by avoiding the edges.

Programming I/O port of ATMega8:

Each port has three i/o registers associated with it which are
designated as DDRx, PORTx, PINx.

Port Registers in ATMega8

DDRx register:
It stands for data direction register. This register is of 8 bits. Value of this
register decides whether the port will act as input port or as output port.
To make any port as input port, the contents of the associated DDRx
register are made 0x00 and to make any port as output port, the contents
of the associated DDRx register are made 0xff.
PORTx register:
This register is responsible for outputting any data to the port. Data to be
outputted to any port is loaded to the corresponding PORTx register after
making the direction of that port as output.
For example:
To send 0x14 to PORTA:DDRA=0xFF;
PINx register:
This register is responsible for inputting data from any port. Data to be
inputted from any port is taken from the corresponding PINx register
after making the direction of that port as input.
For example:
To get data from PORTB:DDRA=0x00;

//var is a character type variable