A4988驱动NEMA步进电机(42步进电机) – 太极创客 | a4988步進馬達
/* Arduino控制NEMA步进电机测试程序(2018-09-25) by太极创客(www.taichi-maker.com) 本示例程序旨在演示如何通过Arduino控制NEMA步进电机。 用户可通过串口监视器控制电机的各个功能 如需获得本示例程序详细电路信息以及如何使用Arduino控制电机的更多知识,请参考太极创客网站: http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/arduino-a4988-nema-stepper-motor/ 控制指令: 顺时针旋转/逆时针旋转-x0/x1 运行步数-z100(走100步) 步进方式-b1(全步),b2(半步),b4(四分),b8(8分),b16(...
/*
Arduino控制NEMA步进电机测试程序 (2018-09-25)
by 太极创客(www.taichi-maker.com)
本示例程序旨在演示如何通过Arduino控制NEMA步进电机。
用户可通过串口监视器控制电机的各个功能
如需获得本示例程序详细电路信息以及如何使用Arduino控制电机的更多知识,请参考太极创客网站:
http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/arduino-a4988-nema-stepper-motor/
控制指令:
顺时针旋转/逆时针旋转 - x0/x1
运行步数 - z100(走100步)
步进方式 - b1(全步),b2(半步),b4(四分),b8(8分),b16(16分)
速度 - d2000(转动速度2000)
允许工作/禁止工作(enable/disable) - g1/g0
睡眠 - m0(sleep)/m1(awake)
*/
// A4988引脚连接Arduino引脚编号
const int dirPin = 2; // Direction
const int stepPin = 3; // Step
const int sleepPin = 4; // Sleep
const int resetPin = 5; // Reset
const int ms3Pin = 6; // Ms3
const int ms2Pin = 7; // Ms2
const int ms1Pin = 8; // Ms1
const int enPin = 9; // Enable
// 步进电机旋转一周步数
const int STEPS_PER_REV = 20...