#include <L298N.h>
const unsigned int IN3 = 17;
const unsigned int IN4 = 16;
const unsigned int ENB = 4;
L298N motor1(ENB, IN3, IN4);
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
motor1.setSpeed(255);
motor1.forward;
delay(5000);
motor1.backward;
delay(5000);
motor1.setSpeed(130);
motor1.forward;
delay(5000);
motor1.backward;
delay(5000);
}
You can import the library in your code using the Arduino IDE going to Sketch -> Include library -> L298N or directly writing the include statement in your code:
// For single motor instance
#include <L298N.h>
// For two motors instance at once
#include <L298NX2.h>