通过Arduino控制带有L293D屏蔽的NEMA 17步进电机

  发布人:amy2025 时间:2025-08-29

使用NEMA 17双极步进电机和L293D电机驱动器屏蔽板精确控制您的项目。按照我们的指南详细说明和解锁您的项目的潜力。

接线图

1. 电源:Arduino上的USB线5V输出。

2. 电机连接:将步进电机的电线连接到L293D的电机通道上:

•蓝线连接M3(OUT1)

•黑线接M3(OUT2)

•绿线接M4(OUT3)

•通往M4的红线(OUT4)

电机通道:确保屏蔽上的电机通道M3和M4正确接线,以控制步进电机。

代码

#include

// Create the motor object using the Adafruit Motor Shield library

AF_Stepper motor(200, 1); // 200 steps per revolution, connected to motor port 2 (M3 and M4)

void setup() {

Serial.begin(9600); // Start serial communication

motor.setSpeed(60); // Set the speed to 60 RPM

}

void loop() {

Serial.println("Clockwise");

motor.step(200, FORWARD, SINGLE); // Move 200 steps clockwise

delay(500);

Serial.println("Counterclockwise");

motor.step(200, BACKWARD, SINGLE); // Move 200 steps counterclockwise

delay(500);

}



关键词: Arduino 电机驱动器 步进电机 L293D

加入微信
获取电子行业最新资讯
搜索微信公众号:EEPW

或用微信扫描左侧二维码

相关电路