A4988 Stepper Motor Driver and Nema17 Stepper Motor with ESP32 & Potentiometer | English Subtitle

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ธ.ค. 2023
  • If you need any custom code for your projects, please contact me on Skype- G B RANJITKAR (message only/no calls) Not free, there will be a fee.
    A4988 Stepper Motor Driver and Nema17 Stepper Motor with ESP32 & Potentiometer | English Subtitle
    #robot #robotics #engineering #education #educational #school #college #learning #code #coading #diy
    Code : code is on the comment below.
    Facebook : / doit20-104218935882053
    Please Subscribe my Channel. ThankYou!

ความคิดเห็น • 4

  • @doit.20
    @doit.20  6 หลายเดือนก่อน

    #include
    // Define pin connections for ESP32
    const int dirPin = 25; // You can choose any suitable GPIO pin
    const int stepPin = 26; // You can choose any suitable GPIO pin
    const int potPin = 14; // Analog input pin for the potentiometer
    // Define motor interface type
    #define motorInterfaceType 1
    // Creates an instance
    AccelStepper myStepper(motorInterfaceType, stepPin, dirPin);
    void setup() {
    // Set motor parameters for smooth movement
    myStepper.setMaxSpeed(700); // Adjust maximum speed (steps per second)
    myStepper.setAcceleration(300); // Adjust acceleration (steps per second squared)
    myStepper.moveTo(6000); // Set initial target position
    }
    void loop() {
    // Read the value from the potentiometer
    int potValue = analogRead(potPin);
    // Map the potentiometer value to a speed range
    int speed = map(potValue, 0, 4095, 0, 700); // ESP32 ADC range is 0-4095
    // Set the speed of the stepper motor
    myStepper.setMaxSpeed(speed);
    // Move the motor
    myStepper.run();
    // Check if the motor has reached the target position
    if (myStepper.distanceToGo() == 0) {
    // Change direction and set a new target position
    if (myStepper.currentPosition() == 6000) {
    myStepper.moveTo(-6000); // Change direction
    } else {
    myStepper.moveTo(6000); // Change direction
    }
    }
    }

  • @iamasgroup
    @iamasgroup 6 หลายเดือนก่อน +1

    What is the value of the potentiometer?

    • @doit.20
      @doit.20  6 หลายเดือนก่อน +1

      You can use any pot 5kΩ to 47kΩ

    • @iamasgroup
      @iamasgroup 6 หลายเดือนก่อน

      @@doit.20 Thank you so much; you make great tutorials.