Arduino Code 5 motors with 3 boards LN298N and ESP8266

I need a program to control 5 electric motors with X,Y,Z,M,N coordinates, which are connected to 3 LN298N boards. The 2 motors are the extruder that makes the square. The coordinates of the square are X,Y. You need to be able to enter these coordinates. Or at least have 5 sliders to move these coordinates (motors). The 3 boards are connected to the pins. The first board 1,2,3,4,5. The second board 6,7,8,9,10. The third board A0,A1,A2,A3,A4,A5. There are also limiters on the X,Y,Z coordinates which are connected to pins 11,12,13. They are needed for the machine to go to 0 position by X,Y,Z coordinates. The control should be implemented over WI-FI using a Wi-Fi module ESP8266 version ESP-01. Can someone help? I made the code, but it doesn't work.

Hi welcome to community

Go through it

And share us the complete code which you tried

1 Like

Please read the forum guidelines to see how to properly post code and some information on making a good post.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please post a wiring diagram. Written descriptions are always more ambiguous than a drawing. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.

Technical data for the motors would also be very helpful to those who wish to assist.

How are all of those components powered?

To what Arduino board are the ancient crap L298 motor drivers connected?

Arduino Uno
5 motors
3 boards LN298N

I make a homemade extruder that lays out a square, and makes 3 more layers on top. The X,Y coordinates are the dimensions of the square. Z is another layer. I need 3 of these layers. It needs to be implemented to be able to specify coordinates in a separate window. The code itself is given below.

#include <Stepper.h>

//define pins for motor control
int motor1Pin1 = 1;
int motor1Pin2 = 2;
int motor1Pin3 = 3;
int motor1Pin4 = 4;

int motor2Pin1 = 6;
int motor2Pin2 = 7;
int motor2Pin3 = 8;
int motor2Pin4 = 9;

int motor3Pin1 = A0;
int motor3Pin2 = A1;
int motor3Pin3 = A2;
int motor3Pin4 = A3;

// determine the number of steps per revolution for each motor
int stepsPerRevolution = 200;

//create instances of the Stepper objects for each motor
Stepper motor1(stepsPerRevolution, motor1Pin1, motor1Pin2, motor1Pin3, motor1Pin4);
Stepper motor2(stepsPerRevolution, motor2Pin1, motor2Pin2, motor2Pin3, motor2Pin4);
Stepper motor3(stepsPerRevolution, motor3Pin1, motor3Pin2, motor3Pin3, motor3Pin4);

// define pins for limit switches
int xLimitPin = 11;
int yLimitPin = 12;
int zLimitPin = 13;

void setup() {
  // set pins for limit switches to the input mode
  pinMode(xLimitPin, INPUT);
  pinMode(yLimitPin, INPUT);
  pinMode(zLimitPin, INPUT);
}

void loop() {
  // check the limit switches and bring the machine to 0 position
  if (digitalRead(xLimitPin) == LOW) {
    motor1.setSpeed(50);
    motor1.step(-100);
  }

  if (digitalRead(yLimitPin) == LOW) {
    motor2.setSpeed(50);
    motor2.step(-100);
  }

  if (digitalRead(zLimitPin) == LOW) {
    motor3.setSpeed(50);
    motor3.step(-100);
  }

  // control X and Y coordinates in window mode

  // control the Z coordinate to draw the next layer
  motor3.setSpeed(50);
  motor3.step(stepsPerRevolution * 3); // move 3 mm upwards

  // control a homemade extruder
}

You have another, duplicate, post >>Arduino Code 5 motors with 3 boards LN298N and ESP8266

That is cross posting and is against the forum rules.

You should have a moderator merge the 2 posts.

Topics merged as suggested.

@lorkei in the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

"It doesn't work" is not a very good description of the issue. Can you be more specific? Do the motors move, make noise, get hot, anything?

Do the limit switches work?

Will you address the requests and questions in post #3? We really need to know what motors you are using and how they are powered at the very least.

does not work - it means that I wrote the code incorrectly. I asked for help with the code.

If you will not cooperate then I can't help. Good luck.

Are you talking about payment? We can make an arrangement.

No, I do not want payment. I only want answers to my questions.

If your hardware is not right, no amount of software will make it work. For instance, the ancient technonolgy L298 motor drivers are not at all suited for modern bipolar stepper motors. Limit switches that are not properly wired will not work right. So I ask for data on the motors and a wiring diagram. No smount of code will fix an underpowered circuit so I ask for the power supply specs.

It is powered by a 12 volt power supply, some old electric motors, markings erased by old age, but everything works, I checked on the test program, all the motors worked, the power is enough.

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