Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino uno driving dc motor in both directions forward and backward using L293d h-bridge motor driver

By EG Projects July 16, 2019

In this tutorial i am going to teach you how to drive a small DC(direct current) motor with arduino uno using L293D h-bridge motor driver ic. I will control the rotation direction(clock and anti clock wise) of dc motor with l293d motor driver controller and arduino uno. Tutorial will help you in understanding how easy it is to rotate the dc motor in both clock wise and anti clock wise direction using l293d and arduino uno. 

Microcontrollers can’t driver Dc motor by them selfs

We all know that microcontrollers them self’s are unable to drive DC motors. Since the current they output on their output pins is not enough to drive a small dc motor. Typically microcontroller I/O pins output (20 mills amperes -40 mills amperes) of currents. Arduino uno gpio pins can output 40 mill amperes of continuous current, still 40 mA is not enough current to drive a dc motor.

External circuit with microcontroller to drive dc motor

Dc motor needs about 100 mills amperes to 250 mills amperes continuous current to rotate and move their spindle or shaft. So its obvious that we require an external source with microcontroller to drive a dc motor. The best solution is to use transistors and mosfets to drive the dc motor. To control the rotation direction of motor we have to use multiple transistors and mosfets. Also we must input the correct logic as program code in arduino to rotate the motor in either directions. ​

Using a pre-assembled dc motor driver

Most popular dc-motor drivers/circuits among embedded designers is an H-bridge circuit. H-bridge is a combination of 4 transistors or mosfets arranged in a fixed linear circuit. H-bridge logic circuit is shown below.
H-bridge logic circuit

H-bridge logic circuit

​Since making an h-bridge circuit is time consuming and the circuit it self is messy and consumes large space, we can go with l293d motor driver. L293d is an h-bridge circuit in a small ic which is easy to use and handle it also occupies less space than making a standard h-bridge circuit with linear components.

If you are new and don’t know about l293d pin out, its internal structure and how to effectively use it? Just take the below tutorial it will help you in understanding the arduino code written below.  

  • L293D pin out and working. ​​

From the above tutorial you can easily understand how to make motor connections with arduino uno pins and l293d motor driver. Each and every step of interfacing a load with l293d is well explained in the above tutorial. 

Arduino dc motor control, L293d Motor Driver – Bidirectional motor control – connections

I am going to use channel 1 of l293d motor driver to drive and control rotation direction of dc motor. The circuit schematic is simple. Ground Pin#4 and 5 of L293D. Supply +5 volts as input to Pin#1 of l293d. Supply +12 volt to Pin#8 of l293d. Arduino digital Pin#7 and 8 are used to control the motor rotation direction. Connect arduino digital Pin#7 to pin#7 of l293d motor driver and Pin#8 to pin#2 of l293d. Now connect your motor to Pin#3 and 6 of L293d. Ground Pin#4 and 5 of l293d channel-1. Arduino can be powered from personal computer of laptop usb port. L293d is powered from an external 12 volt source.
L293d motor driver and controller with arduino controlling rotation direction of dc motor

L293d motor driver and controller with arduino controlling rotation direction of dc motor

Note: I am using Pin#3 and 6 as output because i am using only one side of the ic(L293). If you are using the other side than make sure your connections are right. Note L293D can run two motor’s at a time you can also use it to run just a single motor. Like i did!

L293d motor driver with arduino driving dc motor – Project code

The code of the project is simple. First i defined Pin#7 and 8. Then in void setup function in defined both Pins#7 and 6 as output pins.They can only output a digital signal now. In void loop function i am doing all the direction control stuff.

First i give delay for 2 seconds to make the circuit stable. Note that the arduino void loop function is same like while(1) continuously working function or repeating.

Next i made Pin#7 HIGH and Pin# 8 LOW, this signal goes to the L293d Pin#2 and 7 which made our motor to run in clock or anti clock wise direction depending on your configuration. Motor remains in this condition for 4 seconds then the state of the pins changes.

Now both the pins are at LOW means zero which make the motor to stop and motor stops for 3 seconds, this step is very important because now we want to change the direction and if we change it with out any delay, than it could be dangerous for our circuit and motor driver. when the motor rotates it generates a back emf(electro motive force) in it and when it stops this emf transmits back out to the circuit, which could be harmful. That’s why i stooped the motor for 3 seconds.

Then again i rotate the motor but this time in opposite direction, by making Pin# 8 HIGH and 7 LOW. Motor now rotates in opposite direction for 4 seconds. After it again a delay and motor stops. After these all the steps the loop function repeats and the circuit perform the same steps from start.   

More projects involving microcontrollers and l293d motor driver. Projects are open source. Code and circuits are free one can use and modify every thing of the projects. 

DC Motor Speed Control with L293D

L293D with 8051 Microcontroller

Stm32 microcontroller driving heavy loads

Dc motor control over WiFi using Nodemcu

Code Arduino


Filed Under: Arduino Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How best to synchronise the UCC38C45?
  • Collector Current Low side Has a large drop respect High Side during Miller during Double Pulse Test
  • Diode recovery test Irrm timing.
  • The Analog Gods Hate Me
  • floating node warning in LTSpice

RSS Electro-Tech-Online.com Discussions

  • The Analog Gods Hate Me
  • Display TFT ST7789 (OshonSoft Basic).
  • Fixing board, Easy question HEX SCHMITT
  • Can I make two inputs from one??
  • Home Smoke detectors are all Beeping Batteries are not dead.???

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • How to monitor temperature and humidity on a TFT display with graphics
  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cmÂł density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe