Skip to content
Simple Arduino L298N motor driver Library
C++
Branch: master
Clone or download
Latest commit bdfdf77 May 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode/ipch #update docs May 7, 2019
examples/basic #update docs May 7, 2019
img #add image Mar 10, 2018
.DS_Store #update docs May 7, 2019
L298N.cpp #update docs May 7, 2019
L298N.h #update docs May 7, 2019
LICENSE.md Create LICENSE.md May 7, 2019
README.md Update README.md May 7, 2019
keywords.txt #update docs May 7, 2019
library.properties Update library.properties Mar 10, 2018

README.md

L298N

Simple Arduino L298N Library make for easy way for control DC motor by using L298N Module.

how to use

  • install library to your arduino IDE (Download from github)
  • let see examples

Example

#include <L298N.h>

//pin Left
#define A_ENA 2
#define A_N1 3
#define A_N2 4
#define A_N3 5
#define A_N4 6
#define A_ENB 7

L298N mdA(A_ENA, A_N1, A_N2, A_N3, A_N4, A_ENB);

char junk;
String inputString = "";

void setup()
{
  Serial.begin(9600);
  mdA.begin();
}

void loop()
{

  if (Serial.available())
  {
    while (Serial.available())
    {
      char inChar = (char)Serial.read();
      inputString += inChar;
    }
    Serial.println(inputString);
    while (Serial.available() > 0)
    {
      junk = Serial.read();
    } // clear the serial buffer

    if (inputString == "1")
    {
      mdA.motorLeftForwardClock(150);
    }
    else if (inputString == "2")
    {
      mdA.motorLeftRevertClock(200);
    }
    else if (inputString == "3")
    {
      mdA.motorRightForwardClock(255);
    }
    else if (inputString == "4")
    {
      mdA.motorRightRevertClock(200);
    }
    else if (inputString == "5")
    {
      mdA.motorLeftstop();
      mdA.motorRightstop();
    }
    else if (inputString == "6")
    {
      mdA.motorLeftbreak(100);
    }
    else if (inputString == "7")
    {
      mdA.motorRightbreak(100);
    }

    inputString = "";
  }

} //loop

determine left and right motor

l298n

You can’t perform that action at this time.