Arduino机器人汽车无线控制使用HC-05蓝牙,NRF24L01和HC-12收发器模块

在本教程中,我们将学习如何无线控制我们在上一个视频中制作的Arduino机器人车。我将向您展示三种不同的无线控制方法,使用HC-05蓝牙模块,NRF24L01收发器模块和HC-12长范围无线模块,以及使用智能手机和定制​​的Android应用程序。您可以观看以下视频或阅读下面的书面教程以获取更多详细信息。

我已经有关于如何使用Arduino Board连接和使用每个模块的教程,因此如果您需要更多详细信息,您可以随时检查。与它们中的每一个的链接可以在文章中找到。

Arduino机器人汽车控制使用HC-05蓝牙模块

我们将从中开始蓝牙通信为此目的,我们需要两个HC-05蓝牙模块,需要配置为主设备和从设备。

Arduino机器人汽车HC-05蓝牙控制

我们可以通过在命令中轻松实现这一点,我将操纵杆设置为主人,Arduino机器人汽车成为奴隶。以下是此示例的完整电路原理图:

Arduino机器人汽车HC-05蓝牙控制电路示意图

您可以从下面的链接获取此示例所需的组件:

yaboAG娱乐城披露:这些是附属链接。作为一个亚马逊助理,我从合格的购买中赚取。

源代码

我们将使用相同的代码以前的教程,我们在那里直接使用操纵杆控制Arduino机器人车,我们将对它进行一些修改。

HC-05主代码:

/ * Arduino机器人汽车无线控制使用HC-05 Bluetooth == Master Device  -  Joystick == by Dejan Nedelkovski,www.www.kuaixg.com * /亚搏手机版官方下载 int xaxis,yaxis;void setup(){serial.begin(38400);//蓝牙模块的默认通信率} void循环(){xaxis = analogread(a0);//读取操纵杆x轴yaxis = analogread(a1);//读取操纵杆y轴//通过串行端口发送值到从属HC-05蓝牙设备序列号(Xaxis / 4);//除以4从0-1023转换为0  -  256,(1字节)范围序列.Write(Yaxis / 4);延迟(20);}

主设备或操纵杆处的代码非常简单。我们只需要读取操纵杆的x和y值,实际调节电机的速度,并通过串行端口发送到从属HC-05蓝牙设备。这里我们可以注意到,通过潜水将它们转换为0到1023的操纵杆从0到1023的模拟值将它们转换为0到255。

我们这样做是因为该范围,从0到255,可以在蓝牙设备上发送,作为一个更容易接受的1个字节,或者在Arduino机器人车上。

所以这里,如果串行已经接收了2个字节,x和y值,则使用serial.read()函数,我们将读取它们。

// arduino机器人car //读取来自操纵杆或主蓝牙设备的传入数据(serial.available()> = 2){x = serial.read();延迟(10);y = Serial.read ();}

现在我们只需将值转换回0到1023的范围,适用于下面的电机控制代码,我们已经解释了它在上一个视频中的工作原理。亚博88下载

//从Arduino机器人车//转换回0  -  255范围到0  -  1023,适用于Xaxis = X * 4下方的电机控制代码;yaxis = y * 4;

只需快速注意,在上传代码时,我们需要断开Arduino板的RX和TX引脚。

完整的HC-05从代码:

/ * Arduino机器人汽车无线控制使用HC-05蓝牙==奴隶设备 -  Arduino机器人Car ==由Dejan Nedelkovski,www.www.kuaixg.com * / #define ena 9 #define In1亚搏手机版官方下载 4 #define In2 5 #define In2 5 #define eNB 10#define In3 6 #define In4 7 int Xaxis,Yaxis;unsigned int x = 0;unsigned int y = 0;int motorSpeedA = 0;int motorSpeedB = 0;void setup() {pinMode(enA, OUTPUT);pinMode (enB、输出);pinMode(三机一体、输出);pinMode (in2、输出); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); Serial.begin(38400); // Default communication rate of the Bluetooth module } void loop() { // Default value - no movement when the Joystick stays in the center x = 510 / 4; y = 510 / 4; // Read the incoming data from the Joystick, or the master Bluetooth device while (Serial.available() >= 2) { x = Serial.read(); delay(10); y = Serial.read(); } delay(10); // Convert back the 0 - 255 range to 0 - 1023, suitable for motor control code below xAxis = x*4; yAxis = y*4; // Y-axis used for forward and backward control if (yAxis < 470) { // Set Motor A backward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set Motor B backward digitalWrite(in3, HIGH); digitalWrite(in4, LOW); // Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 470, 0, 0, 255); motorSpeedB = map(yAxis, 470, 0, 0, 255); } else if (yAxis > 550) { // Set Motor A forward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); // Set Motor B forward digitalWrite(in3, LOW); digitalWrite(in4, HIGH); // Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 550, 1023, 0, 255); motorSpeedB = map(yAxis, 550, 1023, 0, 255); } // If joystick stays in middle the motors are not moving else { motorSpeedA = 0; motorSpeedB = 0; } // X-axis used for left and right control if (xAxis < 470) { // Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value int xMapped = map(xAxis, 470, 0, 0, 255); // Move to left - decrease left motor speed, increase right motor speed motorSpeedA = motorSpeedA - xMapped; motorSpeedB = motorSpeedB + xMapped; // Confine the range from 0 to 255 if (motorSpeedA < 0) { motorSpeedA = 0; } if (motorSpeedB > 255) { motorSpeedB = 255; } } if (xAxis > 550) { // Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value int xMapped = map(xAxis, 550, 1023, 0, 255); // Move right - decrease right motor speed, increase left motor speed motorSpeedA = motorSpeedA + xMapped; motorSpeedB = motorSpeedB - xMapped; // Confine the range from 0 to 255 if (motorSpeedA > 255) { motorSpeedA = 255; } if (motorSpeedB < 0) { motorSpeedB = 0; } } // Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70) if (motorSpeedA < 70) { motorSpeedA = 0; } if (motorSpeedB < 70) { motorSpeedB = 0; } analogWrite(enA, motorSpeedA); // Send PWM signal to motor A analogWrite(enB, motorSpeedB); // Send PWM signal to motor B }

Arduino机器人汽车控制使用智能手机和自定义构建Android应用程序

接下来,让我们看看我们如何使用a控制我们的Arduino机器人车自定义构建Android应用程序。机器人车的电路示意图与前一个例子完全相同,HC-05蓝牙模式设置为从设备。

Arduino机器人汽车Android智能手机控制

另一方面,使用麻省理工学院应用程序发明家在线应用程序我们将构建我们自己的Android应用程序,这是它的样子。

所以基本上该应用程序模拟了一个操纵杆,其中出现了两个图像或图像精灵。

麻省理工学院App Inventor操纵杆应用Arduino机器人汽车控制教程

如果我们看看这个应用程序的块,我们可以看到,当操纵杆精灵被拖动时,操纵杆球的图像被移动到手指的当前位置,同时我们发送x和y在蓝牙到Arduino汽车的价值。MIT APP Inventor Joystick应用程序块

使用Serial.read函数,Arduino以与前一个示例相同的方式接受这些值。

//从智能手机Android应用读取传入的数据while (Serial.available() >= 2) {x = Serial.read();延迟(10);y = Serial.read ();}

此外,我们需要做的是将所接收的X和Y值转换为0到1023的范围,适用于下面的电机控制码。这些值取决于Canvas大小,并且我从我的应用程序获得的x和y值为60到220,它使用map()函数我很容易转换它们。

//确保我们收到正确的值if (x > 60 & x < 220) {xAxis = map(x, 220, 60, 1023, 0);//将智能手机X和Y值转换为0 - 1023范围,适合电机控制代码下面的电机}if (Y > 60 & Y < 220) {yAxis = map(Y, 220, 60, 0,1023);}

在应用程序块中,我们还可以看出,当触摸图像精灵时,操纵杆移动回到画布的中心,并将适当的值发送到汽车,以停止移动。您可以在网站文章中找到并下载此应用程序,以及操纵杆的两个图像,以便您可以构建您自己的或修改此应用程序。

你可以下载下面的Android应用程序,以及两张操纵杆的图片:

完整的Arduino代码:

/ * Arduino机器人汽车使用HC-05蓝牙无线控制和定制构建Android应用= =奴隶设备——Arduino机器人汽车由德扬Nedelkovski = = www.HowToMechatronics.com * / # define enA 9 # define in1 4 #定义in2 5 # defi亚搏手机版官方下载ne enB 10 # define in3 6 # define in4 7 int xAxis桠溪;Int x = 0;Int y = 0;int motorSpeedA = 0;int motorSpeedB = 0;void setup() {pinMode(enA, OUTPUT);pinMode (enB、输出);pinMode(三机一体、输出);pinMode (in2、输出);pinMode (in3、输出); pinMode(in4, OUTPUT); Serial.begin(38400); // Default communication rate of the Bluetooth module } void loop() { // Default value - no movement when the Joystick stays in the center xAxis = 510; yAxis = 510; // Read the incoming data from the Smartphone Android App while (Serial.available() >= 2) { x = Serial.read(); delay(10); y = Serial.read(); } delay(10); // Makes sure we receive corrent values if (x > 60 & x < 220) { xAxis = map(x, 220, 60, 1023, 0); // Convert the smartphone X and Y values to 0 - 1023 range, suitable motor for the motor control code below } if (y > 60 & y < 220) { yAxis = map(y, 220, 60, 0, 1023); } // Y-axis used for forward and backward control if (yAxis < 470) { // Set Motor A backward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set Motor B backward digitalWrite(in3, HIGH); digitalWrite(in4, LOW); // Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 470, 0, 0, 255); motorSpeedB = map(yAxis, 470, 0, 0, 255); } else if (yAxis > 550) { // Set Motor A forward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); // Set Motor B forward digitalWrite(in3, LOW); digitalWrite(in4, HIGH); // Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 550, 1023, 0, 255); motorSpeedB = map(yAxis, 550, 1023, 0, 255); } // If joystick stays in middle the motors are not moving else { motorSpeedA = 0; motorSpeedB = 0; } // X-axis used for left and right control if (xAxis < 470) { // Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value int xMapped = map(xAxis, 470, 0, 0, 255); // Move to left - decrease left motor speed, increase right motor speed motorSpeedA = motorSpeedA - xMapped; motorSpeedB = motorSpeedB + xMapped; // Confine the range from 0 to 255 if (motorSpeedA < 0) { motorSpeedA = 0; } if (motorSpeedB > 255) { motorSpeedB = 255; } } if (xAxis > 550) { // Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value int xMapped = map(xAxis, 550, 1023, 0, 255); // Move right - decrease right motor speed, increase left motor speed motorSpeedA = motorSpeedA + xMapped; motorSpeedB = motorSpeedB - xMapped; // Confine the range from 0 to 255 if (motorSpeedA > 255) { motorSpeedA = 255; } if (motorSpeedB < 0) { motorSpeedB = 0; } } // Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70) if (motorSpeedA < 70) { motorSpeedA = 0; } if (motorSpeedB < 70) { motorSpeedB = 0; } analogWrite(enA, motorSpeedA); // Send PWM signal to motor A analogWrite(enB, motorSpeedB); // Send PWM signal to motor B }

Arduino机器人汽车无线控制使用NRF24L01收发器模块

现在我们可以继续下一方法,使用arduino机器人汽车的无线控制NRF24L01收发器模块

Arduino机器人车NRF24L01收发器模块教程

这是电路原理图。我们可以注意到这些模块使用SPI通信,因此与前一个例子相比,我的移动A和使能L298N驱动器的B引脚与Arduino板的引脚标记2和3。NRF24L01无线Arduino机器人汽车控制 - 电路原理图您可以在以下内获取NRF24L01模块亚马逊链接

源代码

对于此示例,我们需要安装RF24库。以与前面示例类似的方式,在定义一些引脚并将模块设置为发射器之后,我们读取操纵杆的x和y值并将其发送到Arduino机器人车的其他NRF24L01模块。

首先,我们可以注意到模拟读数是字符串,它使用String.toCharArray()函数被放入字符数组中。然后使用radio.write()函数,我们将该字符数组数据发送到另一个模块。

变送器代码:

/ * Arduino机器人汽车无线控制使用NRF24L01收发器模块==发射机 -  Joystick ==由Dejan Nedelkovski,www.www.kuaixg.com库:TMRH20 / RF24,HTTPS://github.c亚搏手机版官方下载om/tmrh20/rf24/ * / #include #include  #include  rf24收音机(8,9);// ce,csn const字节地址[6] =“00001”;char xydata [32] =“”;字符串Xaxis,Yaxis;void setup(){serial.begin(9600);radio.begin();radio.openwritingPipe(地址);radio.setpalevel(rf24_pa_min);电台.Stoplistening(); } void loop() { xAxis = analogRead(A0); // Read Joysticks X-axis yAxis = analogRead(A1); // Read Joysticks Y-axis // X value xAxis.toCharArray(xyData, 5); // Put the String (X Value) into a character array radio.write(&xyData, sizeof(xyData)); // Send the array data (X value) to the other NRF24L01 modile // Y value yAxis.toCharArray(xyData, 5); radio.write(&xyData, sizeof(xyData)); delay(20); }

另一方面。在Arduino机器人车上,在将模块定义为接收器之后,我们使用radio.read()函数接受数据。然后使用ATOI()函数我们将接收的数据或从操纵杆的x和y值转换为整数值,这适用于下面的电机控制代码。

//来自Arduino机器人Car的代码 -  NRF24L01示例(radio.Available()){//,如果NRF240L01模块接收到数据无线电.Read(&roceedData,sizeof(roceaddata));//读取数据并将其放入字符数组xaxis = ATOI(&AcceedData [0]);//将数据从字符数组(接收x值)转换为整数延迟(10);radio.read(&roceeddata,sizeof(recaptdata));yaxis = ATOI(&RecodgeData [0]);延迟(10);}

这是简单的,但当然当我已经说过,如果您需要更多详细信息如何连接和设置模块,您可以随时检查我的特定教程。

接收器代码:

/ * Arduino机器人汽车无线控制使用NRF24L01收发器模块==接收器 -  Arduino Robot Car == by Dejan Nedelkovski,www.www.kuaixg.com库:TMRH20 / RF24,HTTPS://gi亚搏手机版官方下载thub.com/tmrh20/rf24/ * /#include  #include  #include  #define ena 2 //注意:先前视频中的引脚9(引脚10用于NRF24L01的SPI通信)#define IN14 #define In2 5 #define eNB 3 //注意:PIN 10在上一个视频#define In3 6 #Define In4 7 RF24收音机(8,9);// ce,csn const字节地址[6] =“00001”;Char RecodatedData [32] =“”;yixis,yaxis;int motorSpeedA = 0;int motorSpeedB = 0;void setup() {pinMode(enA, OUTPUT);pinMode (enB、输出); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); Serial.begin(9600); radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MIN); radio.startListening(); } void loop() { if (radio.available()) { // If the NRF240L01 module received data radio.read(&receivedData, sizeof(receivedData)); // Read the data and put it into character array xAxis = atoi(&receivedData[0]); // Convert the data from the character array (received X value) into integer delay(10); radio.read(&receivedData, sizeof(receivedData)); yAxis = atoi(&receivedData[0]); delay(10); } // Y-axis used for forward and backward control if (yAxis < 470) { // Set Motor A backward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set Motor B backward digitalWrite(in3, HIGH); digitalWrite(in4, LOW); // Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 470, 0, 0, 255); motorSpeedB = map(yAxis, 470, 0, 0, 255); } else if (yAxis > 550) { // Set Motor A forward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); // Set Motor B forward digitalWrite(in3, LOW); digitalWrite(in4, HIGH); // Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 550, 1023, 0, 255); motorSpeedB = map(yAxis, 550, 1023, 0, 255); } // If joystick stays in middle the motors are not moving else { motorSpeedA = 0; motorSpeedB = 0; } // X-axis used for left and right control if (xAxis < 470) { // Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value int xMapped = map(xAxis, 470, 0, 0, 255); // Move to left - decrease left motor speed, increase right motor speed motorSpeedA = motorSpeedA - xMapped; motorSpeedB = motorSpeedB + xMapped; // Confine the range from 0 to 255 if (motorSpeedA < 0) { motorSpeedA = 0; } if (motorSpeedB > 255) { motorSpeedB = 255; } } if (xAxis > 550) { // Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value int xMapped = map(xAxis, 550, 1023, 0, 255); // Move right - decrease right motor speed, increase left motor speed motorSpeedA = motorSpeedA + xMapped; motorSpeedB = motorSpeedB - xMapped; // Confine the range from 0 to 255 if (motorSpeedA > 255) { motorSpeedA = 255; } if (motorSpeedB < 0) { motorSpeedB = 0; } } // Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70) if (motorSpeedA < 70) { motorSpeedA = 0; } if (motorSpeedB < 70) { motorSpeedB = 0; } analogWrite(enA, motorSpeedA); // Send PWM signal to motor A analogWrite(enB, motorSpeedB); // Send PWM signal to motor B }

Arduino机器人汽车无线控制使用HC-12远程收发器

对于Arduino机器人汽车的最后一种无线控制方法,我们将使用HC-12长距离收发器模块。这些模块可以通过高达1.8 km的距离彼此通信。

该示例的电路原理图与HC-05蓝牙模块的电路示意图几乎相同,因为它们通过串行端口使用与Arduino的相同方法进行通信。

Arduino机器人汽车无线控制使用HC-12远程收发器

您可以在以下内获取HC-12收发器模块亚马逊链接

源代码

操纵杆代码与蓝牙通信的码完全相同。我们只是读取操纵杆的模拟值,并使用Serial.Write()函数将它们发送到另一个模块。

变送器代码:

/ * Arduino机器人汽车无线控制使用HC-12远程无线模块==发射器 -  Joystick ==由Dejan Nedelkovski,www.www.kuaixg.com * / int xaxis,yaxis;亚搏手机版官方下载void setup(){serial.begin(9600);//蓝牙模块的默认通信率} void循环(){xaxis = analogread(a0);//读取操纵杆x轴yaxis = analogread(a1);//读取操纵杆y轴//通过串行端口发送值到从属HC-05蓝牙设备序列号(Xaxis / 4);//除以4从0-1023转换为0  -  256,(1字节)范围序列.Write(Yaxis / 4);延迟(20);}

在另一边,随着时间()循环我们等到数据到达,然后使用Serial.read()函数读取它并将其转换回0到1023范围内,适用于下面的电机控制码。

接收器代码:

/ * Arduino机器人汽车无线控制使用HC-12远程无线模块==接收器 -  Arduino机器人车==由Dejan Nedelkovski,www.www.kuaixg.com * / #define ena 9 #define In1 4 #define In亚搏手机版官方下载2 5 #define In2 5 #defineeNB 10 #define In3 6 #Define In4 7 int Xaxis,Yaxis;Int x = 0;Int y = 0;int motorSpeedA = 0;int motorSpeedB = 0;void setup() {pinMode(enA, OUTPUT);pinMode (enB、输出);pinMode(三机一体、输出);pinMode (in2、输出); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); Serial.begin(9600); // Default communication rate of the Bluetooth module } void loop() { // Default value - no movement when the Joystick stays in the center xAxis = 510; yAxis = 510; // Read the incoming data from the while (Serial.available() == 0) {} x = Serial.read(); delay(10); y = Serial.read(); delay(10); // Convert back the 0 - 255 range to 0 - 1023, suitable for motor control code below xAxis = x * 4; yAxis = y * 4; // Y-axis used for forward and backward control if (yAxis < 470) { // Set Motor A backward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); // Set Motor B backward digitalWrite(in3, HIGH); digitalWrite(in4, LOW); // Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 470, 0, 0, 255); motorSpeedB = map(yAxis, 470, 0, 0, 255); } else if (yAxis > 550) { // Set Motor A forward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); // Set Motor B forward digitalWrite(in3, LOW); digitalWrite(in4, HIGH); // Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed motorSpeedA = map(yAxis, 550, 1023, 0, 255); motorSpeedB = map(yAxis, 550, 1023, 0, 255); } // If joystick stays in middle the motors are not moving else { motorSpeedA = 0; motorSpeedB = 0; } // X-axis used for left and right control if (xAxis < 470) { // Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value int xMapped = map(xAxis, 470, 0, 0, 255); // Move to left - decrease left motor speed, increase right motor speed motorSpeedA = motorSpeedA - xMapped; motorSpeedB = motorSpeedB + xMapped; // Confine the range from 0 to 255 if (motorSpeedA < 0) { motorSpeedA = 0; } if (motorSpeedB > 255) { motorSpeedB = 255; } } if (xAxis > 550) { // Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value int xMapped = map(xAxis, 550, 1023, 0, 255); // Move right - decrease right motor speed, increase left motor speed motorSpeedA = motorSpeedA + xMapped; motorSpeedB = motorSpeedB - xMapped; // Confine the range from 0 to 255 if (motorSpeedA > 255) { motorSpeedA = 255; } if (motorSpeedB < 0) { motorSpeedB = 0; } } // Prevent buzzing at low speeds (Adjust according to your motors. My motors couldn't start moving if PWM value was below value of 70) if (motorSpeedA < 70) { motorSpeedA = 0; } if (motorSpeedB < 70) { motorSpeedB = 0; } analogWrite(enA, motorSpeedA); // Send PWM signal to motor A analogWrite(enB, motorSpeedB); // Send PWM signal to motor B }

所以这对本教程来说几乎是一切。随意询问以下意见部分中的任何问题。

53回复

  1. 城市

    非常感谢你
    我打算编写类似的代码,现在我节省了很多时间

    谢谢分享

    PS:由于我在MIT应用程序发明之前从未使用过的项目文件,如果项目文件可用,则基于您的构建更容易进行实验,并学会使用此匹配
    我之所以这么说,是因为我看到在其他项目中,您让项目文件可用。足彩网女欧洲杯

    我订阅了你的YouTube频道......我认为你应该得到更多的订阅者,而不是你到现在的数字..我想你会很快拥有它们

    回复
      • 穆罕默德同名

        感谢一百万兄弟。你已经节省了很多其他的时间并帮助了,以便我们可以做出更多的提前薄薄

  2. 本杰明

    你好,

    我想用smarthphone建造自己的机器人车。我下载了应用程序,我用右电路原理构建机器人。我连接到HC-05,我触摸了操纵杆球,没有发生任何事情。有时我听到来自电机的一些噪音,有时它已经运行,但只有一种方式,只有1个电机。在您的视频中,您谈论画布大小。我在哪里可以看到?
    你有什么想法如何解决这个问题?
    谢谢

    回复
    • Dejan Nedelkovski.

      嗯,您可能需要调整画布大小。此调整应在App块中完成。首先,您应该检查您在手机上触摸的区域中获得的值,然后确保与驱动电机的值匹配。

      回复
      • 纳森

        我如何确定如何确定帆布区域的值?我猜测了64在“获取CurrentX - 64”中和“140-64”的值必须更改......对吗?
        我使用了三星Note3并与本杰明有同样的问题。
        谢谢。

  3. youssef sideh.

    嗨,感谢我想要通过智能手机使用蓝牙的努力工作的努力工作,我实际上根据教程建立了一切,但是当我尝试停止电机时,应用程序会出现问题,它不会停止如果您可以帮助我解决这个问题,电机将略高,我会非常感激
    谢谢

    回复
    • Dejan Nedelkovski.

      嘿,这个问题可能在智能手机应用程序中。在释放应用程序操纵杆时,该应用程序应发送右值,使电机停止旋转,正如所解释的那样。

      回复
  4. Deepti.

    纳米是否必须通过USB插入电力?如果是这样,我们又可以为它提供动力,以便我们可以携带遥控器并不依赖于具有笔记本电脑连接?(对不起,如果这是一个愚蠢的问题,我真的是Arduino和Electronics的新手,这是我的第一个项目之一。)yabo7. com足彩网女欧洲杯

    回复
    • Dejan Nedelkovski.

      您可以使用电池为Arduino供电。Arduino上有一个“VIN”销,可以提供7.2V至12V的电压。这与电源插孔的连接相同,那么12V将通过车载电压调节器,这将使它适用于Arduino 5V。

      回复
  5. Pranav德赛

    嘿,
    我试图制作这辆车。在MIT应用程序Inventor的块中,您将电流x和当前y减去64(拖动图像普通时)。您还从64中减去140(当AignerPrite触摸时)。您还发送140(Send1bytenumber)。
    你能解释这些事情的意思吗?

    谢谢!

    回复
    • Dejan Nedelkovski.

      嘿,画布大小约为130px,所以为了将它定位在屏幕的中间,我需要减去其值的一半,因为x,y定位的值位于画布的左上角。

      回复
      • Pranav德赛

        谢谢!
        在Arduino的教程中,您已经帮助了我很多!
        继续努力吧!

  6. rahul yadav.

    嘿!
    如果我将输入输入到加速度计而不是操纵杆,使用HC-12作为通信设备,我如何改变相同的传输代码?

    谢谢!

    回复
    • Dejan Nedelkovski.

      嗯,您需要读取加速度计数据,并以相同的方式将该数据发送到接收器。当然,代码将取决于加速度计模型,但是您可以检查我的MEMS加速度计教程,该教程解释了如何使用Arduino的加速度计。

      回复
  7. 阴凉

    谢谢很多工作。
    但我面临着问题
    我连接了你告诉我们的所有东西,但其中一个大部分都不工作,另一个只移动了2或3度。我几乎听不到它的声音,在应用上一直给我这个信息
    “无法将259分为1字节”
    是一个解决方案

    回复
    • Dejan Nedelkovski.

      该错误表示当您将259的值发送到Arduino时,该值越多,那么一个字节。您可以注意到,在应用程序中,我们只发送1个字节到Arduino,因此可以发送0到255的值。如果您想要发送更大的值,它不能符合1字节。因此,应该确保只要将值下降到255,你必须以某种方式限制了应用程序中的操纵杆,或者调整你在触摸操纵杆区域时得到的值。

      回复
  8. 特里

    伟大的项目,有原因是否有任何原因,为什么我不能使用Arduino Nano或Micro的作为项目两侧的控制器?

    保持良好的工作,谢谢分享

    回复
  9. 筛选

    您好,我正在研究我的项目,这是通过蓝牙无线控制的。我在YouTube上看了你的视频。我还在使用H桥和12V电源。我该如何做些什么来防止可能是Arduino和H Bridge Safe Temical IC谢谢

    回复
    • 德国

      嘿,很好,如果H-Bridge模块在5V上工作,那么您可以安全地使用Arduino,同时通过VIN PIN(12V到VIN PIN)或电源插孔为Arduino供电。

      回复
  10. 巴里

    首先,我要感谢您,还尝试了至少5个其他类似的项目,没有巨大的结果,我发现了您每次第一次工作的NRFL(我现在建于3)。足彩网女欧洲杯我的孙子们想比赛他们有没有办法将每对(控制器和坦克)设置为自己的频道,以便它们不会相互干扰?。

    谢谢你。

    回复
    • 德国

      我很高兴听到这个消息。好吧是,这是可能的,但请检查RF24库文档您应该在那里进行更多详细信息,目前我没有这样的示例。

      回复
  11. Tyler M Hernandez.

    你好!非常感谢您的教程,我希望为我的工程课使用它。我遵循了你的原理图,将代码上传到Arduino,下载了应用程序,我无法让它正常工作。我可以立即连接到蓝牙模块,但是当我使用操纵杆时,我几乎没有回复。我可以有1个电机有时移动,甚至它始终处于相同的方向。

    任何可能导致这件事的想法吗?I went line by line through the code multiple times, triple checked the circuit, so I think the issue might be the app but I struggle to understand how to use MIT app inventor 2. I tried modifying your app but I can’t get it to work. Any ideas what the issue might be and how to solve it?

    回复
    • 德国

      嘿,听起来你有蓝牙通信有问题。尝试更改波特率,您的HC-05模块可能具有9600的默认波特率。尝试将来自蓝牙的传入数据打印到串行监视器上,并查看您获得了什么样的值。

      回复
  12. 达西哈兰

    你好,
    我已经制作了你的Arduino汽车,非常喜欢它。我试图让应用程序与蓝牙模块连接,但它遇到了问题。我与我创建的汽车有一个差异,我使用了HM-10 BLE蓝牙4.0(MLT-TB05)而不是HC05,因为我有它可用。除了我使用与您在MIT应用程序Inventor 2上创建的应用程序完全相同。

    我已经能够将我的手机与蓝牙模块配对,并可以在MIT AI2伴侣中打开应用程序。然而我无法连接到应用程序内部的模块,我一直收到“错误507:无法连接。设备是否开启?"当我试图连接它的时候。

    I have tried changing the band for communications to 115200, which I understand is the MLT-TB05’s communication frequency but it doesn’t seem to work on either 9600, 38400 or 115200. It may be a firmware issue but I am unsure how to check this or update.

    您是否有任何关于如何获得两个连接的想法?

    P.S.我是你的忠实粉丝,并希望教导我的高中学生如何制作任何和所有项目。足彩网女欧洲杯它让我感到震惊了你对电子工程的了解和你所做的事情。I want to make this project with my year 10’s but I need to make sure the price for all the components is under $10 Australian and I’d need to buy the gearboxes, motor driver and bluetooth module at least to do the project (we can laser print the rest and they have an arduino and batteries already).

    回复
    • 德国

      嘿,谢谢,我很高兴听到你发现我的项目有趣,并希望教学学生与他们一起教学。足彩网女欧洲杯
      我没有使用HC-10 BLE模块,既不尝试一下,看看它是如何工作的。亚博88下载所以在这一刻,我无法帮助你,抱歉。

      回复
  13. Ganesh

    通用ARD-A000067 Arduino Mega 2560 Rev3 - 意大利制造
    我可以使用这个arduino板来制作这个应用程序还是链接中提到的应用程序???

    回复
  14. ichi.

    亲爱的呵呵,

    谢谢你这个有用的文章。我遵循了HC-12部分的所有步骤,但我有一个奇怪的问题,关于电动机A,它只会在一个方向上移动如果放置操纵杆,当你把操纵杆放下时,电机没有移动。我猜它可能与错误的操纵杆有关,所以我改变了它,但问题仍然存在。甚至我也改变了电机。奇怪的部分出现在快速移动操纵杆时,电机A的方向会改变,在操纵杆下仍然没有移动。也许它与PMW功能有关,我不知道。

    回复
    • 德国

      好吧,PowerBank的输出有5V输出,而该直流电机驱动器在12V下工作。也许如果使用不同的驱动程序或/和DC电机,您可以使用PowerBank使用。

      回复
  15. 皮特

    我可以使用更高的RPM DC电机吗?PWM号与何种关系?如果我有一个550 rpm电机正确的话,我必须改变这些电机?

    回复
    • 德国

      当然,您可以使用更高的RPM DC电机。PWM值用于控制电动机速度从0到100%的能力。Arduino接受从0到255的PWM值,其对应于0到100个电源或RPM。

      回复
      • 皮特

        谢谢!我很快就会开始这个项目。我计划在以后添加2个DC电机以使其成为4WD。希望我能做到。再次感谢你!

  16. 克里斯

    你好德州先生,

    你的大粉丝。非常感谢这篇文章。

    蓝牙有点困难。我的HC-05具有9600的默认波特率。我改变了代码并上传了。配对也有效。但是,它看起来没有将应用程序从应用程序发送到蓝牙。我试图在串行循环中进行串行.println - 不可用循环 - 没有值。

    有什么建议么?我花了很多时间试图弄清楚这一点。

    再次感谢,
    克里斯

    回复
  17. Sanjay Pratap Singh.

    非常感谢您的教程,我通过基于您的代码和原理图来使用HC-12模块进行了RC汽车,它一次性工作得很好,谢谢,
    但问题很少 -
    1.向左或向右转,只有一个侧电机运行和其他侧电机应相反,但不断站立。请建议如何修改代码,我想要转动它左侧电机向前运行等向后。
    2.当汽车远离HC-12模块范围时,它保持跑步,不会停止,保持移动,不得不抓住它来阻止它或者必须靠近遥远的汽车。
    3.我的HC-12模块信号质量远远优于NRF24,但它也仅提供了大约10-20MTR的MTR系列,请建议如何进行。
    4.需要添加几个可以通过远程控制的灯光,请建议修改代码。

    提前致谢。

    桑杰

    回复
    • 德国

      嘿,很高兴你听到你成功完成了项目。
      好吧,如果您想要在左转或右转时两个轮子变为相对的话,您需要修改“移动左”中的代码,并“移动右移”“如果”语句部分。例如,对于移动右,需要使用“IN1”和“IN2”引脚设置/更改左电机的旋转方向,反之亦然。
      为了防止汽车丢失信号时,可以添加一个代码,如果模块之间没有通信,则可以添加一个讲述所有动作的代码。检查我的Arduino RC发射器项目,我在那里使用了这个方法,所以你会发现解释你如何做到这一点。
      至于HC-12模块的范围,对于获得最远的通信距离,您需要将模块的波特率设置为最低级别。
      在项目中添加一些led应该很容易。控制它们是灯打开和关闭一个引脚。
      干杯!

      回复
      • Sanjay Pratap Singh.

        谢谢德詹,

        如果您可以向我发送代码来添加以在信号丢失时添加我的代码,我正在努力实现多种方式,但无法成功。

  18. 斯蒂芬西格尔

    你好德詹
    我真的很喜欢你的教程,并建立了许多巨大的成功项目。足彩网女欧洲杯也许您可以帮助我使用我的无线NRF24L01机器人汽车的次要问题。每一个经常,x和y轴都换透 - 即向前移动操纵杆,左右转动汽车,依此类推。我必须关闭发射器并重新打开以纠正。任何想法如何纠正这个故障?
    非常感谢!
    史蒂夫斯。

    回复
    • 德国

      嘿,很高兴听到这个消息。好吧,我建议检查我的DIY Arduino RC发射器项目。我在那里具有相同的例子来控制NRF24L01机器人汽车,但是在无线电通信方面具有比特不同的代码,或发送和接收日期。

      回复

发表评论

您的电子邮件地址不会被公开。

受到推崇的

2019年初学者和爱好者的最佳进入级示波器

为初学者和爱好者最好的示波器

受到推崇的

2019年初学者的8个最佳Arduino Starter Kits

初学者的8个最佳Arduino Starter Kits

受到推崇的

用于初学者和爱好者的最佳3D打印机 -  3D打印

初学者和爱好者的最佳3D打印机