Connect stepper to Arduino/ESP32

Kapoue
Posts: 1
Joined: Tue Sep 12, 2023 10:41 am

Connect stepper to Arduino/ESP32

Postby Kapoue » Tue Sep 12, 2023 10:56 am

Hello,

I am complete newbie in electronic. I have suceeded to connect my stepper motor to the DM542T stepper driver and to an arduino UNO like this:
Image

So now I am trying to use my ESP-32 and I have connected like this. But of course if I am here it is because it doesn't work :(
Image

Here is the pin diagram provided by Az-Delivery:
Image

As I will also connect a screen I would like to use only the free pin left:
Image

I have use the exact same program on both except that I have modify the PIN_DIR and PIN_PUL to adapt the the correct pins I have used.

Code: Select all

#include <Arduino.h>
#include "StepperMotor.h"

// Define pins for the motor
const int dirPin = 8;  // DIR+
const int stepPin = 9; // PUL

// Create an instance of the StepperMotor class
StepperMotor myStepper(dirPin, stepPin);

void setup() {
  // No need for setup here, everything is handled in the class constructor
}

void loop() {
  // Rotate the motor 1000 steps in one direction
  myStepper.moveStepperTo(1000);

  delay(1000); // Wait for one second

  // Rotate the motor 1000 steps in the other direction
  myStepper.moveStepperTo(0);

  delay(1000); // Wait for one second
}

Code: Select all

#ifndef STEPPER_MOTOR_H
#define STEPPER_MOTOR_H

#include <AccelStepper.h>

class StepperMotor {
  private:
    AccelStepper stepper;
    const int dirPin;
    const int stepPin;

  public:
    StepperMotor(int dirPin, int stepPin);
    void moveStepperTo(int position);
};

#endif // STEPPER_MOTOR_H
Did I missed something?

Regards,

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Connect stepper to Arduino/ESP32

Postby lbernstone » Wed Sep 13, 2023 4:43 pm

esp32 gpio runs at 3v3. If the stepper driver needs 5v signals, you will need a voltage shifter.

Who is online

Users browsing this forum: No registered users and 50 guests