电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>电子资料>Android应用程序控制的机器人车

Android应用程序控制的机器人车

2022-11-08 | zip | 0.82 MB | 次下载 | 免费

资料介绍

描述

大家好!这是我的下一个项目,智能手机控制的 Arduino 4WD 机器人汽车或蓝牙 Arduino 机器人。它可以前后左右移动,改变速度,打开/关闭前后灯,也可以喇叭。

这是一个非常简单的设计机器人,您可以轻松构建它。

第 1 步:要求

所需零件:

  • Arduino Uno R3 板
  • 带直流电机和车轮 x4 的底盘 4WD
  • 蓝牙模块HC-06
  • 蜂鸣器

第二步:组装四驱机器人智能汽车底盘

 

第 3 步:接线图

 
poYBAGNonzWAGiapAAmjdYWTAEg694.jpg
按照上面的接线图进行连接。
 

第 4 步:上传机器人代码

#define light_FR  14    //LED Front Right   pin A0 for Arduino Uno#define light_FL  15    //LED Front Left    pin A1 for Arduino Uno #define light_BR  16    //LED Back Right    pin A2 for Arduino Uno #define light_BL  17    //LED Back Left     pin A3 for Arduino Uno #define horn_Buzz 18    //Horn Buzzer       pin A4 for Arduino Uno#define ENA_m1 5        // Enable/speed motor Front Right  #define ENB_m1 6        // Enable/speed motor Back Right #define ENA_m2 10       // Enable/speed motor Front Left #define ENB_m2 11       // Enable/speed motor Back Left#define IN_11  2      // L298N #1 in 1 motor Front Right #define IN_12  3      // L298N #1 in 2 motor Front Right #define IN_13  4      // L298N #1 in 3 motor Back Right #define IN_14  7      // L298N #1 in 4 motor Back Right#define IN_21  8      // L298N #2 in 1 motor Front Left #define IN_22  9      // L298N #2 in 2 motor Front Left #define IN_23  12     // L298N #2 in 3 motor Back Left #define IN_24  13     // L298N #2 in 4 motor Back Leftint command;          //Int to store app command state. int speedCar = 100;   // 50 - 255. int speed_Coeff = 4; boolean lightFront = false; boolean lightBack = false; boolean horn = false;void setup() {          pinMode(light_FR, OUTPUT);     pinMode(light_FL, OUTPUT);     pinMode(light_BR, OUTPUT);     pinMode(light_BL, OUTPUT);     pinMode(horn_Buzz, OUTPUT);         pinMode(ENA_m1, OUTPUT);    pinMode(ENB_m1, OUTPUT);    pinMode(ENA_m2, OUTPUT);    pinMode(ENB_m2, OUTPUT);        pinMode(IN_11, OUTPUT);     pinMode(IN_12, OUTPUT);     pinMode(IN_13, OUTPUT);     pinMode(IN_14, OUTPUT);          pinMode(IN_21, OUTPUT);     pinMode(IN_22, OUTPUT);     pinMode(IN_23, OUTPUT);     pinMode(IN_24, OUTPUT);Serial.begin(9600); } void goAhead(){ digitalWrite(IN_11, HIGH);       digitalWrite(IN_12, LOW);      analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, LOW);       digitalWrite(IN_14, HIGH);      analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, LOW);       digitalWrite(IN_22, HIGH);      analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, HIGH);       digitalWrite(IN_24, LOW);      analogWrite(ENB_m2, speedCar);}void goBack(){ digitalWrite(IN_11, LOW);       digitalWrite(IN_12, HIGH);      analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, HIGH);       digitalWrite(IN_14, LOW);      analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, HIGH);       digitalWrite(IN_22, LOW);      analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, LOW);       digitalWrite(IN_24, HIGH);      analogWrite(ENB_m2, speedCar);}void goRight(){ digitalWrite(IN_11, LOW);       digitalWrite(IN_12, HIGH);      analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, HIGH);       digitalWrite(IN_14, LOW);      analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, LOW);       digitalWrite(IN_22, HIGH);      analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, HIGH);       digitalWrite(IN_24, LOW);      analogWrite(ENB_m2, speedCar);}void goLeft(){digitalWrite(IN_11, HIGH);       digitalWrite(IN_12, LOW);      analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, LOW);       digitalWrite(IN_14, HIGH);      analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, HIGH);       digitalWrite(IN_22, LOW);      analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, LOW);       digitalWrite(IN_24, HIGH);      analogWrite(ENB_m2, speedCar);}void goAheadRight(){              digitalWrite(IN_11, HIGH);       digitalWrite(IN_12, LOW);       analogWrite(ENA_m1, speedCar/speed_Coeff);digitalWrite(IN_13, LOW);       digitalWrite(IN_14, HIGH);       analogWrite(ENB_m1, speedCar/speed_Coeff);digitalWrite(IN_21, LOW);       digitalWrite(IN_22, HIGH);       analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, HIGH);       digitalWrite(IN_24, LOW);       analogWrite(ENB_m2, speedCar);     }void goAheadLeft(){              digitalWrite(IN_11, HIGH);       digitalWrite(IN_12, LOW);       analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, LOW);       digitalWrite(IN_14, HIGH);       analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, LOW);       digitalWrite(IN_22, HIGH);       analogWrite(ENA_m2, speedCar/speed_Coeff);digitalWrite(IN_23, HIGH);       digitalWrite(IN_24, LOW);       analogWrite(ENB_m2, speedCar/speed_Coeff);     }void goBackRight(){ digitalWrite(IN_11, LOW);       digitalWrite(IN_12, HIGH);       analogWrite(ENA_m1, speedCar/speed_Coeff);digitalWrite(IN_13, HIGH);       digitalWrite(IN_14, LOW);       analogWrite(ENB_m1, speedCar/speed_Coeff);digitalWrite(IN_21, HIGH);       digitalWrite(IN_22, LOW);       analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, LOW);       digitalWrite(IN_24, HIGH);       analogWrite(ENB_m2, speedCar);}void goBackLeft(){ digitalWrite(IN_11, LOW);       digitalWrite(IN_12, HIGH);       analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, HIGH);       digitalWrite(IN_14, LOW);       analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, HIGH);       digitalWrite(IN_22, LOW);       analogWrite(ENA_m2, speedCar/speed_Coeff);digitalWrite(IN_23, LOW);       digitalWrite(IN_24, HIGH);       analogWrite(ENB_m2, speedCar/speed_Coeff);}void stopRobot(){ digitalWrite(IN_11, LOW);       digitalWrite(IN_12, LOW);      analogWrite(ENA_m1, speedCar);digitalWrite(IN_13, LOW);       digitalWrite(IN_14, LOW);      analogWrite(ENB_m1, speedCar);digitalWrite(IN_21, LOW);       digitalWrite(IN_22, LOW);      analogWrite(ENA_m2, speedCar);digitalWrite(IN_23, LOW);       digitalWrite(IN_24, LOW);      analogWrite(ENB_m2, speedCar);      }    void loop(){    if (Serial.available() > 0) {  command = Serial.read();  stopRobot();    //Initialize with motors stopped.if (lightFront) {digitalWrite(light_FR, HIGH); digitalWrite(light_FL, HIGH);} if (!lightFront) {digitalWrite(light_FR, LOW); digitalWrite(light_FL, LOW);} if (lightBack) {digitalWrite(light_BR, HIGH); digitalWrite(light_BL, HIGH);} if (!lightBack) {digitalWrite(light_BR, LOW); digitalWrite(light_BL, LOW);} if (horn) {digitalWrite(horn_Buzz, HIGH);} if (!horn) {digitalWrite(horn_Buzz, LOW);}switch (command) { case 'F':goAhead();break; case 'B':goBack();break; case 'L':goLeft();break; case 'R':goRight();break; case 'I':goAheadRight();break; case 'G':goAheadLeft();break; case 'J':goBackRight();break; case 'H':goBackLeft();break; case '0':speedCar = 100;break; case '1':speedCar = 115;break; case '2':speedCar = 130;break; case '3':speedCar = 145;break; case '4':speedCar = 160;break; case '5':speedCar = 175;break; case '6':speedCar = 190;break; case '7':speedCar = 205;break; case '8':speedCar = 220;break; case '9':speedCar = 235;break; case 'q':speedCar = 255;break; case 'W':lightFront = true;break; case 'w':lightFront = false;break; case 'U':lightBack = true;break; case 'u':lightBack = false;break; case 'V':horn = true;break; case 'v':horn = false;break;} } }

第 5 步:注释

在上传代码之前,您必须断开蓝牙模块与 Arduino Uno 板(引脚 0、1)的连接。

第 6 步:下载 Android 应用程序

第 7 步:连接蓝牙模块

要将您的智能手机连接到 Arduino 蓝牙模块 HC-06,我们必须输入 PIN CODE 1234 或 0000。

代码::

第 8 步:完成

一旦您正确完成所有步骤,机器人就可以开始使用了!

谢谢你们!


下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费