Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

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

By EG Projects

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, Microcontroller Projects

 

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.

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!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Adaptive filters fundamental
  • Using LTspice to check Current sense transformer reset?
  • Thermal pad construction on pcb
  • lna+mixer noise figure problem
  • Reference driver for negative/above rail voltages.

RSS Electro-Tech-Online.com Discussions

  • Capacitor to eliminate speaker hum
  • Identify a circuit.
  • How is this tester made?
  • undefined reference header file in proteus
  • Control Bare LCD With ATmega328p
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering