1.功能描述
本文示例所实现的功能为:采用蓝牙远程遥控双节履带机械臂小车进行运动。
2.结构说明
4.app安装与配置
将文末资料中的“蓝牙串口助手.apk”安装到安卓手机中。将蓝牙模块连接到主控板并打开电源,然后在手机上运行蓝牙串口助手。
5.功能实现
编程环境:Arduino 1.8.19 下面提供一个蓝牙远程遥控双节履带机械臂小车运动的参考程序(EODrobot.ino):
/*------------------------------------------------------------------------------------ 版权说明:Copyright 2023 Robottime(Beijing) Technology Co., Ltd. All Rights Reserved. Distributed under MIT license.See file LICENSE for detail or copy at https://opensource.org/licenses/MIT by 机器谱 2023-09-04 https://www.robotway.com/ ------------------------------*/ #include#include #include #include #include String serialString = ""; boolean serialComplete = false; char stringBuf[100]; Protocol protocol; Servo myServo[5]; int data[5]; int olddata[5]; int port[5] = {7,8,12,11,3}; void setup() { Serial.begin(9600); for(int i = 0; i < 5; i++){ data[i] = 201; myServo[i].attach(port[i]); } myServo[0].write(90); myServo[1].write(90); myServo[2].write(10); myServo[3].write(150); myServo[4].write(90); } void loop() { if (serialComplete) { protocol.Analyze(serialString); for(int i = 0; i < 5; i++) data[i] = protocol.parameter.GetAt(i); serialString = ""; serialComplete = false; for(int i = 0; i < 5; i++){ if(olddata[i] != data[i]){ if(data[i] == 201) continue; else if(data[i] > 0 && data[i] < 180){ myServo[i].write(data[i]); } olddata[i] = data[i]; } } } } void serialEvent() { while (Serial.available()) { char inChar = (char)Serial.read(); serialString += inChar; if (inChar == '\n') { serialComplete = true; } } }
资料内容:
①程序源代码
②样机3D文件
③蓝牙串口助手.apk
资料下载地址:双节履带机械臂小车-蓝牙遥控