打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
arduino学习笔记17-步进电机试验前几天我也试验了一下,用的是28BYJ-48 Stepper Motor 12V+ULN2003APG改了改一个代码,现在的效果是电位计控制正反转
  • /*
  • This program drives a unipolar or bipolar stepper motor.
  • The motor is attached to digital pins 8 - 11 of the Arduino.

  • Created 11 Mar. 2007
  • Modified 30 Nov. 2009
  • by Tom Igoe

  • */
  • #include <Stepper.h>

  • const int stepsPerRevolution = 64;  // change this to fit the number of steps per revolution for your motor
  • // initialize the stepper library on pins 8 through 11:
  • Stepper myStepper(stepsPerRevolution, 8,9,10,11);   
  • const int aInPin=A0;
  • int val;

  • void setup() {
  •   // set the speed at 60 rpm:
  •   myStepper.setSpeed(200);
  •   // initialize the serial port:
  •   Serial.begin(9600);
  • }

  • void loop() {
  •   val=analogRead(aInPin);
  •   val=map(val,0,1023,0,99);
  •   Serial.println(val);
  •   // step one revolution  in two direction:
  •   if(val>50){
  •     Serial.println("clockwise");
  •     //原library是整步,整步走的角度是半步走的角度的两倍,半步走的声音比较小,平稳些,启动时最好是半步的走比较稳定
  •     //022中library修改为半步模式不成功???FUCK
  •     //四拍运行时步距角为θ=360度/(revolution*4)(俗称整步),八拍运行时步距角为θ=360度/(revolution*8)(俗称半步)
  •     myStepper.step(stepsPerRevolution/2);//
  •     delay(500);
  •   }
  •   else{
  •     // step one revolution in the other direction:
  •     Serial.println("counterclockwise");
  •     myStepper.step(-stepsPerRevolution/2);
  •     delay(500);
  •   }
  • }
  • 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
    打开APP,阅读全文并永久保存 查看更多类似文章
    猜你喜欢
    类似文章
    【热】打开小程序,算一算2024你的财运
    Arduino步进电机控制示例 – 八色木
    成功用ULN2003驱动板驱动28BYJ
    arduino无驱动运行8毫米的超迷你微型两相四线步进电机
    arduino学习笔记17
    (SKU:DRI0035)步进电机驱动扩展板(TMC260)
    将废弃的扫描仪改造成升降机
    更多类似文章 >>
    生活服务
    热点新闻
    分享 收藏 导长图 关注 下载文章
    绑定账号成功
    后续可登录账号畅享VIP特权!
    如果VIP功能使用有故障,
    可点击这里联系客服!

    联系客服