Codey OnlineBibliothèque de composants Arduino & ESP32 › NEMA17 Stepper Motor
NEMA17 Stepper Motor
Actionneurs

NEMA17 Stepper Motor

Un moteur pas à pas NEMA17 transforme les impulsions de pas en un mouvement angulaire précis grâce à deux bobines électromagnétiques. Il est généralement piloté par un driver de moteur pas à pas via les quatre bornes des bobines du moteur (souvent repérées A+/A− et B+/B−), tandis que les autres bornes repérées sur le connecteur correspondent aux mêmes connexions de bobines dans un autre groupement de broches. Utilisez un câblage adapté du driver pas à pas pour alimenter les bobines A et B dans le bon ordre.

Largeur: 53.6 mm

Brochage — NEMA17 Stepper Motor

Broche Signal Description
1A power Stepper coil 1 terminal A — connect to one output of motor driver phase A
1B power Stepper coil 1 terminal B — connect to the other output of motor driver phase A
2A power Stepper coil 2 terminal A — connect to one output of motor driver phase B
2B power Stepper coil 2 terminal B — connect to the other output of motor driver phase B

Exemple de schéma de câblage — NEMA17 Stepper Motor

De Vers Fil
board:5V x2:VDD red
board:GND x2:GND black
board:D2 x2:STEP green
board:D3 x2:DIR blue
board:D4 x2:EN yellow
board:5V x3:CW red
board:GND x3:CCW black
board:A0 x3:WIPER purple
x2:1A x1:1A cyan
x2:1B x1:1B magenta
x2:2A x1:2A brown
x2:2B x1:2B pink

Exemple de code Arduino — NEMA17 Stepper Motor

Cet exemple a été écrit et vérifié à la compilation pour le arduino-uno. Codey Online l'adapte pour vous à toute autre carte prise en charge.

// Canonical NEMA17 stepper motor example using an A4988-style driver.
// Wiring:
// Arduino D2 -> STEP
// Arduino D3 -> DIR
// Arduino D4 -> EN (active LOW)
// Arduino 5V -> VDD
// Arduino GND -> GND
// Potentiometer CW -> 5V, CCW -> GND, WIPER -> A0
// Motor coils -> driver outputs 1A/1B and 2A/2B

const int STEP_PIN = 2;
const int DIR_PIN  = 3;
const int EN_PIN   = 4;
const int POT_PIN  = A0;

void stepMotor(long steps, bool direction, unsigned int stepDelayMicros) {
  digitalWrite(DIR_PIN, direction ? HIGH : LOW);

  for (long i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(stepDelayMicros);
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(stepDelayMicros);
  }
}

void setup() {
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(EN_PIN, OUTPUT);

  digitalWrite(STEP_PIN, LOW);
  digitalWrite(DIR_PIN, LOW);
  digitalWrite(EN_PIN, HIGH); // disable driver at start

  Serial.begin(9600);
  while (!Serial) { }

  Serial.println("NEMA17 stepper motor demo with A4988 driver");
  Serial.println("Turn the potentiometer to change speed.");
  Serial.println("The motor alternates direction after each full rotation.");
}

void loop() {
  int pot = analogRead(POT_PIN);
  unsigned int stepDelayMicros = map(pot, 0, 1023, 2000, 300);
  const int stepsPerRevolution = 200; // typical 1.8 degree NEMA17 motor

  digitalWrite(EN_PIN, LOW); // enable driver

  Serial.print("Speed control pot=");
  Serial.print(pot);
  Serial.print("  step delay(us)=");
  Serial.println(stepDelayMicros);

  Serial.println("Rotating clockwise...");
  stepMotor(stepsPerRevolution, true, stepDelayMicros);
  delay(500);

  Serial.println("Rotating counterclockwise...");
  stepMotor(stepsPerRevolution, false, stepDelayMicros);
  delay(500);
}

Composants similaires

A4988 Stepper Driver

A4988 Stepper Driver

DRV8825 Driver Board

DRV8825 Driver Board

L298N Motor Driver Board

L298N Motor Driver Board

Left DC Motor

Left DC Motor

Construisez votre projet Arduino ou ESP32 avec l'IA

Décrivez ce que vous voulez créer. Codey Online écrit le code, dessine le schéma de câblage, le compile et flashe votre carte directement depuis le navigateur.

Commencez gratuitement