2 drivers l298n in esp32 for 7 motors

so i am using 2 driver l298n in esp32, so in first driver theres not a problem, but in the second there arent any movement from the motors, im putting 12 volt as an input and this is my code:
#include <Ps3Controller.h>

#define MAX_MOTOR_SPEED 200

const int enA = 19;
const int m1Pin1 = 18;
const int m1Pin2 = 5;

const int m2Pin1 = 17;
const int m2Pin2 = 16;
const int enB = 4;

const int enC = 32;
const int m3Pin1 = 33;
const int m3Pin2 = 25;

const int m4Pin1 = 26;
const int m4Pin2 = 27;
const int enD = 14;

const int Freq = 5000; /* 1 KHz */
//const int Freq2 = 1000;
const int Res = 8;
const int chn1 = 0;
const int chn2 = 1;

bool crossBtn = 0;
bool squareBtn = 0;
bool triangleBtn = 0;
bool circleBtn = 0;

bool maju = 0;
bool mundur = 0;
bool kiri = 0;
bool kanan = 0;

void setupPinModes() {
pinMode(m1Pin1, OUTPUT);
pinMode(m1Pin2, OUTPUT);
pinMode(m2Pin1, OUTPUT);
pinMode(m2Pin2, OUTPUT);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);

pinMode(m3Pin1, OUTPUT);
pinMode(m3Pin2, OUTPUT);
pinMode(m4Pin1, OUTPUT);
pinMode(m4Pin2, OUTPUT);
pinMode(enC, OUTPUT);
pinMode(enD, OUTPUT);

ledcSetup(chn1, Freq, Res);
ledcAttachPin(enA, chn1);
ledcAttachPin(enB, chn1);

ledcSetup(chn2, Freq, Res);
ledcAttachPin(enC, chn2);
ledcAttachPin(enD, chn2);
}

void notify() {
crossBtn = Ps3.data.button.cross;
squareBtn = Ps3.data.button.square;
triangleBtn = Ps3.data.button.triangle;
circleBtn = Ps3.data.button.circle;

maju = Ps3.data.button.up;
mundur = Ps3.data.button.down;
kiri = Ps3.data.button.left;
kanan = Ps3.data.button.right;

if (crossBtn) {
digitalWrite(m1Pin1, HIGH);
digitalWrite(m1Pin2, LOW);
ledcWrite(0, 150);
Serial.println("silang");

}

else if (squareBtn) {
digitalWrite(m1Pin1, LOW);
digitalWrite(m1Pin2, HIGH);
ledcWrite(0, 150);
Serial.println("kotak");

}

else if (circleBtn) {
digitalWrite(m2Pin1, HIGH);
digitalWrite(m2Pin2, LOW);
ledcWrite(0, 150);
Serial.println("bulat");

}

else if (triangleBtn) {
digitalWrite(m2Pin1, LOW);
digitalWrite(m2Pin2, HIGH);
ledcWrite(0, 150);
Serial.println("segitiga");

}

else if (maju) {
digitalWrite(m3Pin1, HIGH);
digitalWrite(m3Pin2, LOW);
digitalWrite(m4Pin1, HIGH);
digitalWrite(m4Pin2, LOW);
ledcWrite(0, 150);
Serial.println("maju");

}

else if (mundur) {
digitalWrite(m3Pin1, LOW);
digitalWrite(m3Pin2, HIGH);
digitalWrite(m4Pin1, LOW);
digitalWrite(m4Pin2, HIGH);
ledcWrite(0, -150);
Serial.println("mundur");
}

else if(kiri){
digitalWrite(m3Pin1, HIGH);
digitalWrite(m3Pin2, LOW);
ledcWrite(0,150);
Serial.println("kiri");

}

else if(kanan){
digitalWrite(m4Pin1, HIGH);
digitalWrite(m4Pin2, LOW);
ledcWrite(0, 150);
Serial.println("kanan");
}

else {
digitalWrite(m2Pin1, LOW);
digitalWrite(m2Pin2, LOW);
digitalWrite(m1Pin1, LOW);
digitalWrite(m1Pin2, LOW);
digitalWrite(m3Pin1, LOW);
digitalWrite(m3Pin2, LOW);
digitalWrite(m4Pin1, LOW);
digitalWrite(m4Pin2, LOW);
ledcWrite(0, 0);
Serial.println("gak mencet kontol");
}

}

void setup() {
setupPinModes();
Serial.begin(115200);
Ps3.attach(notify);
Ps3.attachOnConnect(onConnect);
Ps3.attachOnDisconnect(onDisConnect);
Ps3.begin("00:01:02:03:04:b2");
Serial.println("Ready.");
}

void loop() {
}

void onConnect() {
Serial.println("Connected!.");
}

void onDisConnect() {
ledcWrite(0, 0);
}

so i already tested on serial monitor, and they showed up, all of them, but on button up, left, right, and down, theres no movement on dc motor, but in the square, triangle, circle and cross, theres movement that i wanted, anybody knows why ?

Your post is breaking forum rules because you did not post your code correctly. Please read the forum guide in the sticky post and edit your post to add the code tags.

Also, read the instructions from your instructor and the project kit (Arduino-ESP32?)... you will have a better project experience doing both. Also, try the Arduino-ESP32 forum: ESP32 Arduino - ESP32 Forum

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.