|
本帖最后由 honyfox 于 2013-10-10 17:26 编辑
刚刚上手学习驱动电机,买了张L293D驱动板来驱动28BYJ-48步进电机,但是却一直没成功。
因为缺乏硬件基础,所以查了很多资料,都没能搞清楚错在哪里,在此诚恳向大家求援,请赐教,谢谢!
L293D实拍图
L293D驱动是堆叠在Arduino上的
我的接线颜色顺序对应是1-蓝、2-粉、3-黄、4-橙、5-红,如下:
Arduino驱动代码如下:- #include <Stepper.h>
- #define motorSteps 200 // change this depending on the number of steps
- #define motorPin1 8
- #define motorPin2 9
- #define ledPin 13
- // initialize of the Stepper library:
- Stepper myStepper(motorSteps, motorPin1,motorPin2);
- void setup() {
- // set the motor speed at 60 RPMS:
- myStepper.setSpeed(60);
- // Initialize the Serial port:
- Serial.begin(9600);
- // set up the LED pin:
- pinMode(ledPin, OUTPUT);
- // blink the LED:
- blink(3);
- }
- void loop() {
- // Step forward 100 steps:
- Serial.println("Forward");
- myStepper.step(100);
- delay(500);
- // Step backward 100 steps:
- Serial.println("Backward");
- myStepper.step(-100);
- delay(500);
- }
- // Blink the reset LED:
- void blink(int howManyTimes) {
- int i;
- for (i=0; i< howManyTimes; i++) {
- digitalWrite(ledPin, HIGH);
- delay(200);
- digitalWrite(ledPin, LOW);
- delay(200);
- }
- }
复制代码 网上查到的相关L293D驱动步进电机的资料:
用L293D驱动步进电机
http://www.seattlerobotics.org/encoder/may98/steppers.html
L293D电机驱动板驱动28BYJ48
http://nitocris.over-blog.net/article-motor-drive-shield-l293d-et-28byj48-96288219.html |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|