L298n motors are not running?

Hello. I need your help on my project
I am using Robojax_L298N_DC_motor library on my blynk project in order to run my moters with L298N motor driver it is not working.

#define BLYNK_TEMPLATE_ID ---
#define BLYNK_DEVICE_NAME ---

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial

//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD

#include "BlynkEdgent.h"
#include <Robojax_L298N_DC_motor.h>
#include <ESP32Servo.h>
#include <HCSR04.h>

#define CHA 0
#define ENA 13
#define IN1 12
#define IN2 14

// motor 2 settings
#define IN3 15
#define IN4 2
#define ENB 4
#define CHB 1

const int CCW = 2; // do not change
const int CW  = 1; // do not change

#define motor1 1 // do not change
#define motor2 2 // do not change

Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA, IN3, IN4, ENB, CHB);

const byte triggerPin = 18;
const byte echoPin = 19;
UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);

Servo servo;
int led1 = 32;
int led2 = 33;
int led3 = 25;
int led4 = 23;

int myServo = 5;
float distance;
int pinValue;

BLYNK_WRITE(V0) {
  pinValue = param.asInt();
  digitalWrite(led1, pinValue);
  if (pinValue == 1) {
    Serial.println("DEVICE ON");
  }
  else {
    Serial.println("DEVICE OFF");
  }
}
void hcsr04() {


  // int pinValue=BLYNK_WRITE(V0); //START IF DEVICE is ON, GET VALUE FROM V0

  if (pinValue == 1) {

    float distance = distanceSensor.measureDistanceCm();
    //Serial.println(distance);
    Blynk.virtualWrite(V2, distance);
    if (distance < 200) {
      digitalWrite(led2, HIGH);
      digitalWrite(led3, LOW);
      digitalWrite(led4, LOW);
    }
    else {
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led2, LOW);
    }
  }
  else {
    Blynk.virtualWrite(V2, 0.00);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
  }
}
BLYNK_WRITE(V3) {
  int forward = param.asInt();
    
  if (forward ==1) {
  robot.rotate(motor1, 80, CW);//run motor1 at 60% speed in CW direction
  robot.rotate(motor2, 80, CCW);//run motor1 at 60% speed in CW direction
  }
  else {
  robot.brake(1);
  robot.brake(2);
  }
  }
  

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);
}

void setup()
{
  Serial.begin(115200);
  delay(100);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  robot.begin();
  servo.attach(myServo);
  BlynkEdgent.begin();
  timer.setInterval(500L, hcsr04);
}

void loop() {
  BlynkEdgent.run();
  timer.run();
}

If I use library examle on my esp32 it is working.

/*
 * Library Example for L298N Module to control DC motors
 * 
 * This code is to control single motor. For two motor control, please open L298N_DC_2_Motors
 * this code is ready for ESP32
 * Watch video instructions for this code:  https://youtu.be/2JTMqURJTwg
 * 
 * Written by Ahmad Shamshiri on Dec 24, 2019 
 * in Ajax, Ontario, Canada. www.robojax.com
 * 
  Need wiring diagram from this code: Purchase My course on Udemy.com http://robojax.com/L/?id=62
 * 
  * 
 * Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon http://robojax.com/L/?id=63

or make donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <Robojax_L298N_DC_motor.h>
// motor 1 settings
#define CHA 0
#define ENA 13 // this pin must be PWM enabled pin if Arduino board is used
#define IN1 12
#define IN2 14

// motor 2 settings
#define IN3 15
#define IN4 2
#define ENB 4// this pin must be PWM enabled pin if Arduino board is used
#define CHB 1

const int CCW = 2; // do not change
const int CW  = 1; // do not change

#define motor1 1 // do not change
#define motor2 2 // do not change

// for single motor
//Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA, true);	

// for two motors without debug information	// Watch video instruciton for this line: https://youtu.be/2JTMqURJTwg
Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA,  IN3, IN4, ENB, CHB);

// fore two motors with debut information
//Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA, IN3, IN4, ENB, CHB, true);

void setup() {
  Serial.begin(115200);
  robot.begin();
  //L298N DC Motor by Robojax.com

}

void loop() {
  
 // robot.demo(1);
  robot.rotate(motor1, 80, CW);//run motor1 at 60% speed in CW direction
  robot.rotate(motor2, 80, CCW);//run motor1 at 60% speed in CW direction
  
  // Robojax L298N Library. Watch video instruciton https://youtu.be/2JTMqURJTwg
}

I cannot undestand what is the problem. Please help!

How have you configured your datastreams?

What does your serial monitor show?

Have you amended the custom board configuration in Settings.h to resolve the GPIO4 pin conflict?

Pete.

Thank you Pete for qiuck respond.
I have changed pins for motor2.

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial

//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD

#include "BlynkEdgent.h"
#include <Robojax_L298N_DC_motor.h>
#include <ESP32Servo.h>
#include <HCSR04.h>

#define CHA 0
#define ENA 13
#define IN1 12
#define IN2 14

// motor 2 settings
#define IN3 15
#define IN4 5
#define ENB 21
#define CHB 1

const int CCW = 2; // do not change
const int CW  = 1; // do not change

#define motor1 1 // do not change
#define motor2 2 // do not change

Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA, IN3, IN4, ENB, CHB, true);

const byte triggerPin = 18;
const byte echoPin = 19;
UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);

Servo servo;
int led1 = 32;
int led2 = 33;
int led3 = 25;
int led4 = 23;

int myServo = 5;
float distance;
int pinValue;

BLYNK_WRITE(V0) {
  pinValue = param.asInt();
  digitalWrite(led1, pinValue);
  if (pinValue == 1) {
    Serial.println("DEVICE ON");
  }
  else {
    Serial.println("DEVICE OFF");
  }
}
void hcsr04() {


  // int pinValue=BLYNK_WRITE(V0); //START IF DEVICE is ON, GET VALUE FROM V0

  if (pinValue == 1) {

    float distance = distanceSensor.measureDistanceCm();
    //Serial.println(distance);
    Blynk.virtualWrite(V2, distance);
    if (distance < 200) {
      digitalWrite(led2, HIGH);
      digitalWrite(led3, LOW);
      digitalWrite(led4, LOW);
    }
    else {
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led2, LOW);
    }
  }
  else {
    Blynk.virtualWrite(V2, 0.00);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
  }
}
BLYNK_WRITE(V3) {
  int forward = param.asInt();
    
  if (forward ==1) {
  robot.rotate(motor1, 80, CW);//run motor1 at 60% speed in CW direction
  robot.rotate(motor2, 80, CCW);//run motor1 at 60% speed in CW direction
  }
  else {
  robot.brake(1);
  robot.brake(2);
  }
  }
  

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);
}

void setup()
{
  Serial.begin(115200);
  delay(100);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  robot.begin();
  servo.attach(myServo);
  BlynkEdgent.begin();
  timer.setInterval(500L, hcsr04);
}

void loop() {
  BlynkEdgent.run();
  timer.run();
}

Result is same. motor1 giving sound like it is working in small rate of rotation. But it not rotating in 80%

Thank you Pete,
Do you know any other library for l298n motor driver which works well with ESP32 and BLYNK

Screenshots of your serial monitor tell us very little, especially when it doesn’t show the period from booting your device.

Copy and paste the serial output, and put triple backticks around it in your post.
Triple backticks look like this:
```

No, I’ve never used motors with Blynk.

Pete.

Thank you Pete,

Arduino IDE 1.8.16 not showing more information.

Here I take monitoring information from Arduino IDE 2.0.0 Beta.11


New Line
115200 baud
9:53:28.004 -> ets Jun  8 2016 00:22:57
9:53:28.055 -> 
9:53:28.058 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
9:53:28.107 -> configsip: 0, SPIWP:0xee
9:53:28.137 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
9:53:28.189 -> mode:DIO, clock div:1
9:53:28.206 -> load:0x3fff0018,len:4
9:53:28.224 -> load:0x3fff001c,len:1216
9:53:28.241 -> ho 0 tail 12 room 4
9:53:28.259 -> load:0x40078000,len:10944
9:53:28.286 -> load:0x40080400,len:6388
9:53:28.304 -> entry 0x400806b4
9:53:28.322 -> Robojax.com L298N Motor Library
9:53:28.471 -> Dual Motor Demo
9:53:28.488 -> [311] 
9:53:28.648 ->     ___  __          __
9:53:28.691 ->    / _ )/ /_ _____  / /__
9:53:28.742 ->   / _  / / // / _ \/  '_/
9:53:28.753 ->  /____/_/\_, /_//_/_/\_\
9:53:28.772 ->         /___/ v1.0.1 on ESP32
9:53:28.820 -> 
9:53:28.820 -> [312] --------------------------
9:53:28.856 -> [315] Product:  LED blink
9:53:28.875 -> [317] Hardware: 1.0.0
9:53:28.908 -> [319] Firmware: 0.1.0 (build Oct 26 2021 16:14:53)
9:53:28.975 -> [324] Token:    ...dBnc
9:53:29.008 -> [326] Device:   ESP32 @ 240MHz
9:53:29.056 -> [329] MAC:      F0:08:D1:D3:46:D4
9:53:29.105 -> [332] Flash:    4096K
9:53:29.126 -> [334] ESP sdk:  v3.3.5-1-g85c43024c
9:53:29.175 -> [337] Chip rev: 1
9:53:29.209 -> [339] Free mem: 277192
9:53:29.256 -> [341] --------------------------
9:53:29.308 -> [344] INIT => CONNECTING_NET
9:53:29.357 -> [346] Connecting to WiFi: UGE_MAX
9:53:29.407 -> [2700] Using Dynamic IP: 192.168.41.52
9:53:31.144 -> [2701] CONNECTING_NET => CONNECTING_CLOUD
9:53:31.224 -> [2710] Connecting to blynk.cloud:443
9:53:31.325 -> [5156] Certificate OK
9:53:33.545 -> [5459] Ready (ping: 301ms).
9:53:33.892 -> [5596] CONNECTING_CLOUD => RUNNING
9:53:34.051 -> DEVICE OFF
9:53:34.225 -> Motor 1 CW at 80% duty 3264 pin 12 LOW  pin 14 HIGH
9:53:47.335 -> Motor 2 CCW at 80% duty 3264 pin 15 HIGH  pin 5 LOW
9:53:47.434 -> Motor 1 Braked
9:53:52.556 -> Motor 2 Braked
9:53:52.620 -> DEVICE ON
9:53:55.383 -> DEVICE OFF
9:53:59.523 -> Motor 1 CW at 80% duty 3264 pin 12 LOW  pin 14 HIGH
9:54:01.333 -> Motor 2 CCW at 80% duty 3264 pin 15 HIGH  pin 5 LOW
9:54:01.406 -> Motor 1 Braked
9:54:04.227 -> Motor 2 Braked
9:54:04.259 -> 

Hey GUYS,
Thank you for your advice. I used code from another guys from this forum.
Please close this subject.

if someone needs my help on L298N.
here what i did.


#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial

//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD

#include "BlynkEdgent.h"
#include <Robojax_L298N_DC_motor.h>
#include <ESP32Servo.h>
#include <HCSR04.h>

int ENA = 13;
int IN1 = 12;
int IN2 = 14;

int IN3 = 27;
int IN4 = 26;
int ENB = 25;


const byte triggerPin = 18;
const byte echoPin = 19;
UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);

int led1 = 2;
int led2 = 15;
int led3 = 22;
int led4 = 23;

int myServo = 5;
float distance;
int startDevice;

BLYNK_WRITE(V0) {
  startDevice = param.asInt();
  digitalWrite(led1, startDevice);
  if (startDevice == 1) {
    Serial.println("DEVICE ON");
  }
  else {
    Serial.println("DEVICE OFF");
  }
}
void hcsr04() {


  // int pinValue=BLYNK_WRITE(V0); //START IF DEVICE is ON, GET VALUE FROM V0

  if (startDevice == 1) {

    float distance = distanceSensor.measureDistanceCm();
    //Serial.println(distance);
    Blynk.virtualWrite(V2, distance);
    if (distance < 200) {
      digitalWrite(led2, HIGH);
      digitalWrite(led3, LOW);
      digitalWrite(led4, LOW);
    }
    else {
      digitalWrite(led3, HIGH);
      digitalWrite(led4, HIGH);
      digitalWrite(led2, LOW);
    }
  }
  else {
    Blynk.virtualWrite(V2, 0.00);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
  }
}

BLYNK_WRITE(V3)  {
  
  if (startDevice == 1) {
  int forwardButton = param.asInt();
  if (forwardButton ==1)
  {
    goForward();
    //open valve
  }
  else {
    StopM();
  }
}else {
    StopM();
  }
}
BLYNK_WRITE(V4)  {
  
  if (startDevice == 1) {
  int backwardButton = param.asInt();
  if (backwardButton ==1)
  {
    goBackward();
    //open valve
  }
  else {
    StopM();
  }
}else {
    StopM();
  }
}

BLYNK_WRITE(V5)  {
  
  if (startDevice == 1) {
  int leftButton = param.asInt();
  if (leftButton ==1)
  {
    turnLeft();
    //open valve
  }
  else {
    StopM();
  }
}else {
    StopM();
  }
}

BLYNK_WRITE(V6)  {
  
  if (startDevice == 1) {
  int rightButton = param.asInt();
  if (rightButton ==1)
  {
    turnRight();
    //open valve
  }
  else {
    StopM();
  }
}else {
    StopM();
  }
}

void goForward()                       //forward with speed val
{
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENA, 255);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  digitalWrite(ENB, 255);
  Serial.println("Forward");
}

void goBackward()                     // secont function
{
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENA, 255);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  digitalWrite(ENB, 255);
  Serial.println("Backward");

}
void turnRight()                       //forward with speed val
{
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENA, 255);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  digitalWrite(ENB, 255);
  Serial.println("Right");
}

void turnLeft()                     // secont function
{
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENA, 255);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  digitalWrite(ENB, 255);
  Serial.println("Left");
}

void StopM()                     //third function
{
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  Serial.println("Stoped");
}


BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6);
}

void setup()
{
  Serial.begin(115200);
  delay(100);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);

  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);

  BlynkEdgent.begin();
  timer.setInterval(500L, hcsr04);
  //timer.setInterval(500L, hcsr04);
}
void loop() {
  BlynkEdgent.run();
  timer.run();
}