top of page

Interfacing a DC Motor with LPC2148-Micrcontroller

DC Motors are widely used in embedded systems. This tutorial explains driving a DC motor using ARM-7 Architecture based LPC2148 Microcontroller.

DC motors are available in different ratings. Selection of a motor depends on the application for which the motor is used. In this example we are using a 12-V DC motor. The current required ton drive the motor is provided by a motor driving IC: L293D. This IC is designed to provide up to 600 mA current at 4.5 V- 36 V range.

PIN Configuration:



1 (EN 1,2)

Enable (Active high) channel 1 and 2

2, 7, 10, 15

Driver Inputs

3, 6, 11, 14

Driver Outputs

9 (EN 3, 4)

Enable (Active High) channel 3 and 4

8 (Vcc2)

4.5 - 36 V

16 (Vcc1)

5 v power supply pin for internal logic of the IC

Circuit Diagram:

A single L293D IC can drive two DC motors. In this example we are only controlling the motor which is connected to OUT1 and OUT2 pins of L293D.

A switch is also connected to P0.26 to turn on and turn off the motor. The system will turn off the motor when the switch is pressed.




void motor1_on(void);

void motor1_off(void);

int main()




int a;



a=IO0PIN & (1<<26);

if(a==0) /* The switch is open */


else /* The switch is pressed */



return 0;


void motor1_on()





void motor1_off()




37 views0 comments

Recent Posts

See All

In microcontroller programming we have to write or read certain registers. The questions is how to access these registers ?. The register or a memory location can easily be accessed using pointers

In this blog I will explain use of bitwise operators for performing some operations which are often required for microcontrollers programming. Bitwise operators: & (AND), | (OR) , ~ (NOT) , ^ (XOR)

Post: Blog2_Post
bottom of page