通過(guò)Arduino控制帶有L293D屏蔽的NEMA 17步進(jìn)電機(jī)
掃描二維碼
隨時(shí)隨地手機(jī)看文章
使用NEMA 17雙極步進(jìn)電機(jī)和L293D電機(jī)驅(qū)動(dòng)器屏蔽板精確控制您的項(xiàng)目。按照我們的指南詳細(xì)說(shuō)明和解鎖您的項(xiàng)目的潛力。
接線圖
1. 電源:Arduino上的USB線5V輸出。
2. 電機(jī)連接:將步進(jìn)電機(jī)的電線連接到L293D的電機(jī)通道上:
?藍(lán)線連接M3(OUT1)
?黑線接M3(OUT2)
?綠線接M4(OUT3)
?通往M4的紅線(OUT4)
電機(jī)通道:確保屏蔽上的電機(jī)通道M3和M4正確接線,以控制步進(jìn)電機(jī)。
代碼
#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