# L29x H Bridge Arduino Library

1,708

27

Published

## Introduction: L29x H Bridge Arduino Library

In this tutorial I'll show you a library developed by Lorenzo Daidone and ElettRobotics. With this library, distributed under the terms of the GNU Lesser General Public License, you can handle one or more h-bridges with some easy functions.

For any questions don't hesitate to write me at: email.

Follow steps to use this library properly!

Unzip file and move the "L29x-Arduino-Library-master" directory on Documents > Arduino > libraries.

To use library, Open Arduino IDE and include it.

#include <L29x.h>

Don't forget to press "All steps" button below! you'll see all steps listed! ↓

## Step 2: Take a Look Into Library!

The library allows you to control one or more h-bridges in a easy way.

L29x class contains five public methods:

• fwd(speed); Move motor in forward direction. Specify in parenthesis the speed. Speed must be an integer number between 0 and 255.
• bwd(speed); Move motor in forward direction. Specify in parenthesis the speed. Speed must be an integer number between 0 and 255.
• coast(); Disables motor and makes it rotate by inertia
• brake(); Stops motor with a net braking
• toggle(); Invert forward and backward reference.

Before calling any methods of the library, you have to initialize pins. To make it, before #include <L29x.h> and after void setup() { } you should write:

L29x name_you_want(in1, in2, enable);

• in1: arduino pin number for first direction pin
• in2: arduino pin number for second direction pin
• enable: arduino pin number for enable h-bridge. Pay attention IT MUST BE A PWM PIN!

## Step 3: Example Sketch

In this example sketch I used Arduino UNO rev 3.

#include <L29x.h>

L29x motorA(13, 12, 11);

void setup()
{

//motorA.toggle(); // if forward produces

// backward rotation, delete comment

}

void loop()

{

motorA.fwd(255);
delay(2000);
motorA.bwd(255);
delay(2000);
motorA.coast();
delay(1000);

}

Write me at email.
Visit: http://elettrobotics.com
If you liked this tutorial thumbs up in our Facebook page: https://www.facebook.com/elettrobotics/

## Recommendations

• ### Arduino Class

70,828 Enrolled