1. 功能描述
本文提供的示例所實現(xiàn)的功能為:用手機APP遙控斜三角履帶底盤樣機實現(xiàn)移動,包括前進、停止、后退、原地左轉(zhuǎn)、原地右轉(zhuǎn)。
2. 電子硬件
在這個示例中,采用了以下硬件,請大家參考:
Basra主控板(兼容Arduino Uno)、Bigfish2.1擴展板、7.4V鋰電池、藍牙串口模塊
為斜三角履帶底盤樣機安裝藍牙串口模塊,斜三角履帶底盤樣機有兩種擺放方式:


車身右側(cè)為安裝了藍牙串口模塊的主控板,左側(cè)控制板請忽略
3. 示例程序
編程環(huán)境:Arduino 1.8.19
程序通過使用if語句來判斷讀取到的串口的不同字符值來匹配不同的動作,從而實現(xiàn)對機器人的遠(yuǎn)程控制。
接收到“1”的時候,執(zhí)行前進;
接收到“2”的時候,執(zhí)行后退;
接收到“3”的時候,執(zhí)行左轉(zhuǎn);
接收到“4”的時候,執(zhí)行右轉(zhuǎn);
接收到“5”的時候,執(zhí)行停止;
手機APP的鍵值按上述規(guī)則進行配置,然后單片機接收到不同的信息,對應(yīng)執(zhí)行不同的動作。
例程代碼(robot_ble_control.ino)如下:
|
/*------------------------------------------------------------------------------------ 版權(quán)說明:Copyright 2022 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 機器譜 2022-9-28 https://www.robotway.com/ ------------------------------ 實功能: 從串口(藍牙)接收字符,根據(jù)不同字符分別做出前進、后退、停止、原地左轉(zhuǎn)、原地右轉(zhuǎn)的動作。 ----------------------------------------------------- 實驗接線: 左輪:D9,D10 右輪:D5,D6。 ------------------------------------------------------------------------------------*/ int _ABVAR_1_Bluetooth_data = 0 ; void Left(); void Stop(); void Right(); void Back(); void Forward(); void setup() { Serial.begin(9600); pinMode( 5 , OUTPUT); pinMode( 6 , OUTPUT); pinMode( 9 , OUTPUT); pinMode( 10 , OUTPUT); } void loop() { _ABVAR_1_Bluetooth_data = Serial.parseInt() ; if (( ( _ABVAR_1_Bluetooth_data ) > ( 0 ) )) { if (( ( _ABVAR_1_Bluetooth_data ) == ( 1 ) )) { Forward(); } if (( ( _ABVAR_1_Bluetooth_data ) == ( 2 ) )) { Back(); } if (( ( _ABVAR_1_Bluetooth_data ) == ( 3 ) )) { Left(); } if (( ( _ABVAR_1_Bluetooth_data ) == ( 4 ) )) { Right(); } if (( ( _ABVAR_1_Bluetooth_data ) == ( 5 ) )) { Stop(); } } } void Right() { digitalWrite( 5 , HIGH ); digitalWrite( 6 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 10 , HIGH ); } void Back() { digitalWrite( 5 , HIGH ); digitalWrite( 6 , LOW ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , LOW ); } void Left() { digitalWrite( 5 , LOW ); digitalWrite( 6 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , LOW ); } void Forward() { digitalWrite( 5 , LOW ); digitalWrite( 6 , HIGH ); digitalWrite( 9 , LOW ); digitalWrite( 10 , HIGH ); } void Stop() { digitalWrite( 5 , HIGH ); digitalWrite( 6 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , HIGH ); } |
審核編輯 黃昊宇
-
機器人
+關(guān)注
關(guān)注
213文章
31074瀏覽量
222189 -
藍牙
+關(guān)注
關(guān)注
119文章
6313瀏覽量
178690
發(fā)布評論請先 登錄
基于CW32的藍牙無刷遙控車案列
智能底盤電機驅(qū)動應(yīng)用方案
格陸博科技亮相蓋世汽車2025底盤大會
智能語音遙控器低功耗BLE藍牙芯片
破解智能底盤測試4大難題:imc提供一體化解決方案
藍牙語音遙控器方案 NRF52840、HS6621
珈港科技JC511安全藍牙芯片簡介
索尼推出無線藍牙拍攝手柄GP-VPT3與遙控器RMT-VP2
藍牙語音遙控器:智能家居的智慧控制核心
藍牙語音遙控器:智能家居的智慧控制核心
藍牙語音遙控器 低功耗芯片選型HS6621CxC/OM6621
藍牙語音遙控國產(chǎn)適用芯片HS6621
藍牙無線遙控小車
KT6368A的藍牙芯片新增抖音翻頁點贊自拍遙控器說明書 包含AT指令
藍牙遙控履帶底盤行駛
評論