极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

123
返回列表 发新帖
楼主: 外星人

L293D电机模块 + 超声波测距模块 做的arduino小车

[复制链接]
发表于 2015-10-10 15:28:48 | 显示全部楼层
如果只用了两个电机 应该其他两个的电机插口能用于其他模块吧  比如我用红外线接受模块来接收遥控信号
回复 支持 反对

使用道具 举报

发表于 2015-10-31 22:49:06 | 显示全部楼层
你好,请教一下,如果我再想添加蓝牙接收器该怎么样连接了,已经没有接口可以用了
回复 支持 反对

使用道具 举报

发表于 2016-3-21 17:31:26 | 显示全部楼层
本帖最后由 pig881 于 2016-3-21 17:51 编辑

1.请问楼主使用两套电源还是一套?指南里说要分开电源,是要两套电池吗?

2.另外楼主没有加散热片吗?我发现L293D很烫手啊
回复 支持 反对

使用道具 举报

发表于 2016-3-29 10:45:31 | 显示全部楼层
笨小鸟and坏小猪 发表于 2015-5-29 07:28
已经解决。

我现在也总是编译出错,你是怎么解决的?
回复 支持 反对

使用道具 举报

发表于 2016-3-30 10:22:19 | 显示全部楼层
顶一个啊,赞赞赞,涨姿势了,知道还有这种内置的万向轮,
回复 支持 反对

使用道具 举报

发表于 2016-4-2 09:36:42 | 显示全部楼层
用楼主的代码 报这个错事为什么?
E:\杞?欢\鍗曠墖鏈? 瀛︿範\ARDUINO\xiaoche-bizhang\xiaoche-bizhang.ino:6:22: note: in expansion of macro 'MOTOR12_64KHZ'

exit status 1
Error compiling for board Arduino Leonardo.
回复 支持 反对

使用道具 举报

发表于 2016-4-3 10:17:42 | 显示全部楼层
楼主直接把 L293 插在arduINO 上用的么?
回复 支持 反对

使用道具 举报

发表于 2016-4-5 21:58:54 | 显示全部楼层
这是增加超声测距功能吗,如果用于对移动目标的跟踪,用于探测目标转向如何做?
回复 支持 反对

使用道具 举报

发表于 2016-4-22 10:24:53 | 显示全部楼层
你的代码有错误的地方,如果定义的不变,在接线时候讲该插2口的擦13口,该插13的插2就行了
回复 支持 反对

使用道具 举报

发表于 2016-5-7 20:44:13 | 显示全部楼层
怎么是编译有误啊
回复 支持 反对

使用道具 举报

发表于 2016-5-22 17:15:44 | 显示全部楼层
楼主,如果接入三个超声波测距怎么接呢?我做了但是超声测距模块不管用啊,求解
  1. #include <AFMotor.h>
  2. int inputPin1=15;  // 定义超声波Trig
  3. int outputPin1=14; // 定义超声波Echo
  4. int inputPin2=16;  // 定义超声波Trig
  5. int outputPin2=17;
  6. int inputPin3=18;  // 定义超声波Trig
  7. int outputPin3=19;
  8. float distanceL;
  9. float distanceR;
  10. float distanceF;
  11. AF_DCMotor motor1(1, MOTOR12_64KHZ);// 创建电机#1号,速度是64KHz pwm
  12. AF_DCMotor motor2(2, MOTOR12_64KHZ);// 创建电机#2号,速度是64KHz pwm
  13. AF_DCMotor motor3(3, MOTOR34_64KHZ);// 创建电机#3号,速度是64KHz pwm
  14. AF_DCMotor motor4(4, MOTOR34_64KHZ);// 创建电机#4号,速度是64KHz pwm
  15. void setup()
  16. {
  17.   Serial.begin(9600);
  18.   pinMode(inputPin1, INPUT);
  19.   pinMode(outputPin1, OUTPUT);
  20. pinMode(inputPin2, INPUT);
  21. pinMode(outputPin2, OUTPUT);
  22. pinMode(inputPin3, INPUT);
  23. pinMode(outputPin3, OUTPUT);
  24. }
  25. void loop()
  26. {
  27.   digitalWrite(outputPin1, LOW); // 使发出发出超声波信号接口低电平2μs
  28.   delayMicroseconds(2);
  29.   digitalWrite(outputPin1, HIGH); // 使发出发出超声波信号接口高电平10μs,这里是至少10μs
  30.   delayMicroseconds(10);
  31.   digitalWrite(outputPin1, LOW);  
  32.   // 保持发出超声波信号接口低电平
  33.   int distanceL = pulseIn(inputPin1, HIGH);  // 读出脉冲时间
  34.   distanceL= distanceL/58;   // 将脉冲时间转化为距离(单位:厘米)
  35.   Serial.println(distanceL);   //输出距离值                 
  36.   delay(50);
  37. digitalWrite(outputPin2, LOW); // 使发出发出超声波信号接口低电平2μs
  38.   delayMicroseconds(2);
  39.   digitalWrite(outputPin2, HIGH); // 使发出发出超声波信号接口高电平10μs,这里是至少10μs
  40.   delayMicroseconds(10);
  41.   digitalWrite(outputPin2, LOW);  
  42.   // 保持发出超声波信号接口低电平
  43.   int distanceF= pulseIn(inputPin2, HIGH);  // 读出脉冲时间
  44.   distanceF=distanceF/58;   // 将脉冲时间转化为距离(单位:厘米)
  45.   Serial.println(distanceF);   //输出距离值                 
  46.   delay(50);
  47. digitalWrite(outputPin3, LOW); // 使发出发出超声波信号接口低电平2μs
  48.   delayMicroseconds(2);
  49.   digitalWrite(outputPin3, HIGH); // 使发出发出超声波信号接口高电平10μs,这里是至少10μs
  50.   delayMicroseconds(10);
  51.   digitalWrite(outputPin3, LOW);  
  52.   // 保持发出超声波信号接口低电平
  53.   int distanceR= pulseIn(inputPin3, HIGH);  // 读出脉冲时间
  54.   distanceR=distanceR/58;   // 将脉冲时间转化为距离(单位:厘米)
  55.   Serial.println(distanceR);   //输出距离值                 
  56.   delay(50);   
  57.   if (distanceL==50&distanceF==50&distanceR==50)    //等于50厘米就停止
  58.   {
  59.      motor1.run(RELEASE);// 电机停止
  60.      motor2.run(RELEASE);// 电机停止
  61. motor3.run(RELEASE);// 电机停止
  62. motor4.run(RELEASE);// 电机停止
  63. }
  64.   if (distanceL> 50&distanceF>50&distanceR>50)   //大于50厘米就前进
  65.   {
  66.     motor1.run(FORWARD);// 电机前进
  67.     motor1.setSpeed(255);// 设置电机速度,从200/255之间任意
  68. motor2.run(FORWARD);// 电机前进
  69. motor2.setSpeed(255);// 设置电机速度,从200/255之间任意
  70.   motor3.run(FORWARD);// 电机前进
  71. motor3.setSpeed(255);// 设置电机速度,从200/255之间任意
  72. motor4.run(FORWARD);// 电机前进
  73. motor4.setSpeed(255);// 设置电机速度,从200/255之间任意
  74. }
  75.   if (distanceL< 50&distanceF< 50&distanceR< 50)   //小于50厘米就后退
  76.   {
  77.     motor1.run(BACKWARD);// 电机后退
  78.     motor1.setSpeed(255);// 设置电机速度,从200/255之间任意
  79. motor2.run(BACKWARD);// 电机后退
  80. motor2.setSpeed(255);// 设置电机速度,从200/255之间任意
  81. motor3.run(BACKWARD);// 电机后退
  82. motor3.setSpeed(255);// 设置电机速度,从200/255之间任意
  83. motor4.run(BACKWARD);// 电机后退
  84. motor4.setSpeed(255);// 设置电机速度,从200/255之间任意
  85. }
  86. }
复制代码
回复 支持 反对

使用道具 举报

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

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

Archiver|联系我们|极客工坊

GMT+8, 2024-4-20 16:20 , Processed in 0.048460 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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