通过Arduino控制带有L293D屏蔽的NEMA 17步进电机
扫描二维码
随时随地手机看文章
使用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);
}
本文编译自hackster.io