Hi guys, in this article we will see how to interface DC motor with 8051.

Components Required

  • 8051 Microcontroller – 1
  • 8051 Program Dumper- 1
  • DC Motor – 1
  • L293 Driver Module – 1
  • Breadboard – 1
  • Jumper wires

L293D is a motor driver. As its name suggests it can drive a motor (normally DC motors up-to certain range). Since the output voltage of 8051 is limited to 5V only thus motors with higher required voltage need some drivers to provide them their desired input voltage.

What L293D does is, it takes the TTL (0/5v) input from the output pins of 8051 microcontroller and forwards the output through itself of higher voltage(required by DC motors).

Connecting a DC motor directly to the pins of 8051 would not work. It may even damage the microcontroller.

L293D is a 16-pin IC which can control a set of two DC motors simultaneously in any direction. It means that you can control two DC motor with a single L293D IC. 

The l293d can drive small and quiet big motors as well.

It works on the concept of H-bridge. H-bridge is a circuit which allows the voltage to be flown in either direction. As you know voltage need to change its direction for being able to rotate the motor in clockwise or anticlockwise direction, Hence H-bridge IC are ideal for driving a DC motor.

L293D PinoutThere are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the motor, the pin 1 and 9 need to be high. For driving the motor with left H-bridge you need to enable pin 1 to high. And for right H-Bridge you need to make the pin 9 to high. If anyone of the either pin1 or pin9 goes low then the motor in the corresponding section will suspend working. It’s like a switch.

There are 4 input pins for this l293d, pin 2, 7 on the left and pin 15 ,10 on the right. Left input pins will regulate the rotation of motor connected across left side and right input for motor on the right hand side. The motors are rotated on the basis of the inputs provided across the input pins as LOGIC 0 or LOGIC 1.

In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.

Let’s consider a Motor connected on left side output pins (pin 3,6). For rotating the motor in clockwise direction the input pins has to be provided with Logic 1 and Logic 0.   

• Pin 2 = Logic 1 and Pin 7 = Logic 0 | Clockwise Direction
• Pin 2 = Logic 0 and Pin 7 = Logic 1 | Anticlockwise Direction
• Pin 2 = Logic 0 and Pin 7 = Logic 0 | Idle [No rotation] [Hi-Impedance state]
• Pin 2 = Logic 1 and Pin 7 = Logic 1 | Idle [No rotation]

In a very similar way the motor can also operated across input pin 15,10 for motor on the right hand side.

VCC is the voltage that it needs for its own internal operation 5v; l293D will not use this voltage for driving the motor. For driving the motor it has a separate provision to provide motor supply VSS.  L293d will use this to drive the motor. It means if you want to operate a motor at 9V then you need to provide a Supply of 9V across VSS Motor supply.

The maximum voltage for VSS motor supply is 36V. It can supply a max current of 600mA per channel. Since it can drive motors Up to 36v hence you can drive pretty big motors with this l293d.

VCC pin 16 is the voltage (in this case 5V) for its own internal Operation. The maximum voltage ranges from 5v and up-to 36v.



sbit motor_1 = P2^0;
sbit motor_2 = P2^1;

void delay(unsigned int t)
	unsigned int i;

void main()
    motor_1 = 1;
    motor_2 = 0; //Rotates Motor  Clockwise
    motor_1 = 1;
    motor_2 = 1; //Stops Motor
    motor_1 = 0;
    motor_2 = 1; //Rotates Motor anti Clockwise
    motor_1 = 0;
    motor_2 = 0; //Stops Motor

Thanks for reading this article for any assistance or doubts comment below.

Download Code

By Devilal

Leave a Reply

Your email address will not be published. Required fields are marked *