gpt4 book ai didi

Connecting an HC05 bluetooth module to a Pololu A-Star 32U4 Prime SV microSD(将HC 05蓝牙模块连接到Pololu A-Star 32 U4 Prime SV microSD)

转载 作者:bug小助手 更新时间:2023-10-25 23:01:36 26 4
gpt4 key购买 nike



I am needing to connect an HC)% bluetooth module to a A-Star 32U4 Prime SV microSD and am unable to get it to work. For context I have a Pololu Dual G2 High-Power Motor Driver 24v18 Shield for Arduino attached to it.

我需要将蓝牙模块连接到A-Star 32U4 Prime SV microSD,但无法使其工作。作为背景,我有一个Pololu双G2大功率电机驱动器24v18盾牌Arduino连接到它。


The project is a bluetooth controlled tank robot. Am I missing a library or something?

该项目是一个蓝牙控制的坦克机器人。我是不是错过了一个图书馆什么的?


I have connected the module to pins 0 and 1 as normal in an Arduino Uno and used the regular functions to try and get t working

我已经像往常一样将模块连接到Arduino Uno的0号和1号针脚上,并使用常规功能尝试让t工作


#include "DualG2HighPowerMotorShield.h"
#include <SoftwareSerial.h>

// Create an instance of the motor shield class
DualG2HighPowerMotorShield24v18 md;

// Set up SoftwareSerial for Bluetooth on pins 7 (RX) and 6 (TX)
SoftwareSerial btSerial(0, 1);

char command; // To store the incoming command from the Bluetooth
module

void stopIfFault()
{
if (md.getM1Fault() || md.getM2Fault())
{
md.disableDrivers();
while (1); // Halt execution if there's a fault
}
}

void setup()
{
btSerial.begin(9600); // Start the SoftwareSerial for Bluetooth
communication
md.init();
md.calibrateCurrentOffsets();
delay(10);
}

void loop()
{
md.enableDrivers();
delay(1);

// Check if data is available to read from the Bluetooth module
if (btSerial.available()) {
command = btSerial.read(); // Read the incoming byte

switch(command) {
case 'N': // Forward
md.setM1Speed(255); // Full speed forward for M1
md.setM2Speed(255); // Full speed forward for M2
break;
case 'S': // Backward
md.setM1Speed(-255); // Full speed backward for M1
md.setM2Speed(-255); // Full speed backward for M2
break;
case 'E': // Turn left
md.setM1Speed(-255); // Full speed backward for M1
md.setM2Speed(255); // Full speed forward for M2
break;
case 'W': // Turn right
md.setM1Speed(255); // Full speed forward for M1
md.setM2Speed(-255); // Full speed backward for M2
break;
case '0': // Stop
md.setM1Speed(0); // Stop M1
md.setM2Speed(0); // Stop M2
break;
}
}

stopIfFault(); // Check for any faults

md.disableDrivers(); // Put the MOSFET drivers into sleep mode.
delay(500);
}

更多回答

How could anyone here know if you are missing a library? You didn't post any of the code. You say you used the pins for an UNO. Is your board an UNO?

这里的人怎么会知道你是不是错过了一个图书馆?你没有发布任何代码。你说你把别针用在了UNO身上。你的董事会是UNO吗?

Soryr I have never used this platform before and thought I was being straight forward. The Microcontroller is a A-Star 32U4 Prime SV microSD which I have installed the library for, the motor shield is DualG2HighPowerMotorShield.h Which I have also installed the library for. Hope this helps

抱歉,我从来没有使用过这个平台之前,并认为我是直截了当的。微控制器是一个A-Star 32 U4 Prime SV microSD,我已经安装了库,电机屏蔽是DualG2HighPowerMotorShield.h,我也安装了库。希望这有帮助

优秀答案推荐

You are atempting to use SoftwareSerial on pins 0 and 1. Those are the pins for your normal serial port. If you want to use 0 and 1 then you use normal Serial to communicate. If you want to use SoftwareSerial so you can use the normal serial port for debugging, then you should choose different pins for the software serial instance.

您正在尝试在引脚0和1上使用SoftwareSerial。这些引脚是您的普通串口的引脚。如果您想使用0和1,那么您可以使用普通串口进行通信。如果您想使用SoftwareSerial以便可以使用普通的串口进行调试,那么您应该为软件串口实例选择不同的引脚。


更多回答

Thank you. I will try this and fingers crossed

谢谢。我要试试这个,祈祷吧。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com