极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

楼主: eagler8

【Arduino】168种传感器系列实验(170)---L293D四路电机驱动板

[复制链接]
 楼主| 发表于 2020-11-13 17:38:24 | 显示全部楼层
  1. /*
  2.   【Arduino】168种传感器模块系列实验(资料+代码+图形+仿真)
  3.   实验一百七十:L293D四路电机驱动板 motor control shield 马达板
  4.   Adafruit Motor Shield模块 Arduino AFMotor 电机扩展板

  5.   1、安装库:百度搜索“AFMotor库”— 下载 — 拷贝到Arduino-libraries 文件夹中
  6.   2、实验之九:测试M1M2M3M4电机前进与后退
  7. */

  8. #include <AFMotor.h>

  9. // 创建对象
  10. AF_DCMotor motor1(1);
  11. AF_DCMotor motor2(2);
  12. AF_DCMotor motor3(3);
  13. AF_DCMotor motor4(4);


  14. // 主程序开始
  15. void setup() {

  16. }
  17. void loop() {
  18.   motor1.setSpeed(200);
  19.   motor1.run(FORWARD);
  20.   motor2.setSpeed(200);
  21.   motor2.run(FORWARD);
  22.   motor3.setSpeed(200);
  23.   motor3.run(FORWARD);
  24.   motor4.setSpeed(200);
  25.   motor4.run(FORWARD);
  26.   delay(2000);
  27.   
  28.   motor1.setSpeed(0);
  29.   motor1.run(RELEASE);
  30.   motor2.setSpeed(0);
  31.   motor2.run(RELEASE);
  32.   motor3.setSpeed(0);
  33.   motor3.run(RELEASE);
  34.   motor4.setSpeed(0);
  35.   motor4.run(RELEASE);
  36.   delay(1000);
  37.   
  38.   motor1.setSpeed(200);
  39.   motor1.run(BACKWARD);
  40.   motor2.setSpeed(200);
  41.   motor2.run(BACKWARD);
  42.   motor3.setSpeed(200);
  43.   motor3.run(BACKWARD);
  44.   motor4.setSpeed(200);
  45.   motor4.run(BACKWARD);
  46.   delay(2000);
  47.   
  48.   motor1.setSpeed(0);
  49.   motor1.run(RELEASE);
  50.   motor2.setSpeed(0);
  51.   motor2.run(RELEASE);
  52.   motor3.setSpeed(0);
  53.   motor3.run(RELEASE);
  54.   motor4.setSpeed(0);
  55.   motor4.run(RELEASE);
  56.   delay(1000);
  57. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-29 20:36:27 | 显示全部楼层
实验开源仿真编程(linkboy V4.1)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-30 17:05:39 | 显示全部楼层
用这款电机驱动扩展板做了一辆麦克纳姆轮小车

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-30 18:03:41 | 显示全部楼层
麦克纳姆轮车子运动模式图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-30 18:06:23 | 显示全部楼层
实验仿真编程(linkboy V4.1)之二

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-30 18:16:12 | 显示全部楼层
使用AFMotor电机扩展板的麦克纳姆轮小车(视频)

https://v.youku.com/v_show/id_XN ... m=a2hzp.8253869.0.0

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-30 10:01 , Processed in 0.040521 second(s), 15 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表