28BYJ-48单极性步进电机程序控制

28BYJ-48单极性步进电机程序控制

1.28BYJ-48单极性步进电机介绍

http://www.taichi-maker.com/homepage/reference-index/motor-reference-index/28byj-48-stepper-motor-intro/

2.编写程序控制步进电机

2.1.硬件搭建

http://www.taichi-maker.com/homepage/reference-index/arduino-library-index/stepper-library/

2.2.控制电机正反转示例

/*
 * Stepper_Motor
 * 步进电机驱动,实现正反转
 */
void setup() {
  // put your setup code here, to run once:
  for (int i = 8; i < 12; i++) {
    pinMode(i, OUTPUT);
  }
}

void clockwise(int num) {
  for (int count = 0; count < num; count++) {
    for (int i = 8; i < 12; i++) {
      digitalWrite(i, HIGH);
      delay(30);
      digitalWrite(i, LOW);
    }
  }
}

void anticlockwise(int num) {
  for (int count = 0; count < num; count++) {
    for (int i = 11; i > 7; i--) {
      digitalWrite(i, HIGH);
      delay(3);
      digitalWrite(i, LOW);
    }
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  clockwise(512);
  delay(100);
  anticlockwise(512);
}

2.3.stepper库控制电机

http://www.taichi-maker.com/homepage/reference-index/arduino-library-index/stepper-library/

2.4.stepper库介绍

http://www.taichi-maker.com/homepage/reference-index/arduino-library-index/stepper-library/#function

3.步进电机应用

https://blog.csdn.net/weixin_41659040/article/details/134814562