L298 Dual H-Bridge Motor driver

l298

The Funduino Tracking Maze also comes with a L298 Dual H-Bridge Motor driver to control the two wheels of the robot.  It’s designed to drive inductive loads, such as relays, solenoids, DC and stepping motors. It can also let us drive two independent DC motors, controlling the speed and direction of each one .

The connections on the board are fairly simple to understand:

motorsconnections

Here we have several connectors for the motors (from left to right):

Motor A Power Motor B
VCC + GND VMS (vcc) + GND + 5v (external power) Vcc + GND
Note: To connect to arduino, we use VMS + GND. NOT 5v

channels

The PINS connections,  we have 8 (From left to right):

  • 5v
  • GND
  • ENB ( Motor B enable PIN)
  • IN4 (Motor B direction 2 PIN)
  • IN3 (Motor B direction 1 PIN)
  • IN2 (Motor A direction 2 PIN)
  • IN1 (Motor A direction 1 PIN)
  • ENA (Motor A enable PIN)

So, here’s a small resume of directions and how to control them:

Enable Motor HIGH – Enable LOW – Disable Motor
Direction 1 IN1 – HIGH IN2 – LOW
Direction 2 IN1 – LOW IN2 – HIGH
Coasting IN1 – LOW IN2 – LOW
Break IN1 – HIGH IN2 – HIGH

Bellow is a small code to test both DC motors. Here is the connections:

Arduino PIN Dual H-Bridge L298
10 ENA
9 ENB
2 IN1
3 IN2
4 IN3
5 IN4

connections1

And now, a little program with some functions defined for directions:

One Reply to “L298 Dual H-Bridge Motor driver”

Leave a Reply

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