L298n Arduino Library

Introduction: L298n Arduino Library

About: Short way,Everything Arduino,AVR... C++,C# and Basic. Full home automatization is my dream I love playing whith stuff that can kill you or fry you like in hell. If you want me to help you with various project…

The L298n is a simple dual channel motor controler for Arduino.Featuring functions like direction change and PWM
speed control makes it easy and fun to use.And it is cheap,realy cheap.
You can get it on ebay for as low as 2$

But it is hard to find a good library for it,so i made one.
Download link https://drive.google.com/open?id=0Bxra0Xe0UREkZWdSZ2ExUGVEN3M

All you need to do is download the .h file and include it in your arduino sketch using:

#include "l298n_lib.h"

In setup part you need to initialize pins used to connect module and arduino:

set_pins (IN1,IN2,IN3,IN4,enableA,enableB);

enable pins must be pwm pins

example;

set_pins(2,3,4,5,9,11);

To controll motors in loop part of code you can write following commands:

dmot('F',127)....dmot means right motor,F is for Forward and 127 is pwm speed,can range from 0 to 255
lmot('B',127)...lmot means left motor,B is for Backward and 127 is pwm speed,can range from 0 to 255

And you can stop motors by:

dmot_stop();
lmot_stop():

Using this commands whith some serial communication and case statements can yield a very nice RC wireless car,the exaple will be included in file.

If you have read all to this point,thank you.

Follow me on twitter @ivica3730k

Have fun and have a nice day.

1 Person Made This Project!

Recommendations

  • Mason Jar Speed Challenge

    Mason Jar Speed Challenge
  • Bikes Challenge

    Bikes Challenge
  • Remix Contest

    Remix Contest

6 Discussions

0
bihezande
bihezande

1 year ago

please can you help me to connect arduino ,NRF24L01AND TWO L298n h bridge driver motor

0
awe070707
awe070707

3 years ago

hi i think this module no need library..

0
Malcom Blanc
Malcom Blanc

3 years ago

I am having trouble downloading the .h file, any help?

0
jeanlouisquero
jeanlouisquero

3 years ago

une précision

j'ai mis

A precision I put

analogWrite(ENA,500);au lieu de zero idem pour ENB

seul les moteurs ENA fonctionnent

Only ENA engines operate