World's Fastest PCB Manufacturing
My Message
Suggestions
Account

Get started now

Log In

or

Sign Up

My ALLPCB

My Orders Shipping Address Balance Account Settings My SNS Profile
0
  • Home
  • Instant Online Quote Alternate Text
    • PCB Instant Quote
    • PCB Assembly Quote
    • SMD-Stencil Quote
  • PCB Assembly
  • PCB Capabilities
  • Feedback
  • Resources
    • Sponsorship
    • PCB Softwares
    • Units Conversion
    • FAQ
  • About Us
    • About Us
    • Why Us
    • Contact Us
    • News
Log In Sign Up
  • Home
  • Instant Online Quote
    • PCB Instant Quote
    • PCB Assembly Quote
    • SMD-Stencil Quote
  • PCB Assembly
  • PCB Capabilities
  • Feedback
  • Resources
    • Sponsorship
    • PCB Softwares
    • Units Conversion
    • FAQ
  • About Us
    • About Us
    • Why Us
    • Contact Us
    • News
service@ALLPCB.com
Thank you very much for your valuable suggestion!
We will solve it as soon as possible!

Controlling a DC Motor by Using Arduino

2017/1/22 19:14:05

By connecting an L298 bridge IC to an Arduino, you can control a DC motor.
A direct current, or DC, motor is the most common type of motor. DC motors normally have just two leads, one positive and one negative. If you connect these two leads directly to a battery, the motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.
To control the direction of the spin of DC motor, without changing the way that the leads are connected, you can use a circuit called an H-Bridge. An H bridge is an electronic circuit that can drive the motor in both directions. H-bridges are used in many different applications, one of the most common being to control motors in robots. It is called an H-bridge because it uses four transistors connected in such a way that the schematic diagram looks like an "H."
You can use discrete transistors to make this circuit, but for this tutorial, we will be using the L298 H-Bridge IC. The L298 can control the speed and direction of DC motors and stepper motors and can control two motors simultaneously. Its current rating is 2A for each motor. At these currents, however, you will need to use heat sinks.
Hardware Required
  • 1 x L298 bridge IC
  • 1 x DC motor
  • 1 x Arduino Mega2560
  • 1 x breadboard
  • 10 x jumper wires
The schematic above shows how to connect the L298 IC to control two motors. There are three input pins for each motor, including Input1 (IN1), Input2 (IN2), and Enable1 (EN1) for Motor1 and Input3, Input4, and Enable2 for Motor2.
Since we will be controlling only one motor in this tutorial, we will connect the Arduino to IN1 (pin 5), IN2 (pin 7), and Enable1 (pin 6) of the L298 IC. Pins 5 and 7 are digital, i.e. ON or OFF inputs, while pin 6 needs a pulse-width modulated (PWM) signal to control the motor speed.
The following table shows which direction the motor will turn based on the digital values of IN1 and IN2.
IN1 IN2 MOTOR
BRAKE
1 FORWARD
1 BACKWARD
1 1 BRAKE
IN1 pin of the L298 IC is connected to pin 8 of the Arduino while IN2 is connected to pin 9. These two digital pins of Arduino control the direction of the motor. The EN A pin of IC is connected to the PWM pin 2 of Arduino. This will control the speed of the motor.
To set the values of Arduino pins 8 and 9, we will use the digitalWrite() function, and to set the value of pin 2, we will use the using analogWrite() function.
Below is a photo of the set up.
Setup
  1. Connect 5V and ground of the IC to 5V and ground of Arduino.
  • Connect the motor to pins 2 and 3 of the IC.
  • Connect IN1 of the IC to pin 8 of Arduino.
  • Connect IN2 of the IC to pin 9 of Arduino.
  • Connect EN1 of IC to pin 2 of Arduino.
  • Connect SENS A pin of IC to the ground.
  • Connect the Arduino using Arduino USB cable and upload the program to the Arduino using Arduino IDE software.
  • Provide power to the Arduino board using power supply, battery or USB cable.
  • The motor should now run first in the clockwise (CW) direction for 3 seconds and then counter-clockwise (CCW) for 3 seconds.
    • 2761
    • 1
    • 326
    Post Comment

      Mikael

      2017/1/24 19:14:05

      Nice content you’ve posted in here

      You might like

      Vasiliy

      • Threads

        2

      • Following

        0

      • Followers

        0

      PCB Prototype

      PCB Instant Quote

      x mm

      Quantity

      Quote Now

      PCB Assembly

      SMT-Stencil

      • 12
      Products & Service
      PCB Capabilities
      Aluminum PCB Service
      PCB Assembly Service
      SMT-Stencil
      Quotation & Feedback
      Online Auto-Quotation
      PCB Assembly Quote
      Quote by Salesperson
      Customer Reviews
      Customer Support
      FAQ
      Community
      Sponsorship
      Referral Program
      About Us
      About Us
      Why Us
      Contact Us
      News
      Resource Details
      PCB Software
      Units Conversion
      service@allpcb.com central_support@allpcb.com
      Follow Us:
      Facebook Youtube Twitter Tumblr Youtube
      Certification: Certification
      Our Preferred Partners: Our Preferred Partners

      Please send Gerbers to service@ALLPCB.com for quotation © ALLPCB.com,All Rights Reserved Privacy PolicySitemap

      Secure Site by GoDaddy.com This site has earned the McAfee SECURE certification.