2 RX 和 2 TX 将数据从 Arduino 发送到 Android [英] 2 RX and 2 TX send data from Arduino to Android

查看:28
本文介绍了2 RX 和 2 TX 将数据从 Arduino 发送到 Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设备连接到我的 Arduino UNO 的 RX 和 TX 引脚,我需要更多的 RX 和 TX 引脚才能通过蓝牙将数据发送到 Android.我计划使用两个引脚 SoftwareSerial 转换为 RX 和 TX 以与蓝牙模块一起使用.我想这是可能的.我已经阅读了该主题,但我发现的大多数内容是建立连接并将数据从 Android 发送到 Arduino.我认为对我来说,Amarino 图书馆是可能的.如果到目前为止我计划的一切都很好,我有很大的疑问.我如何将连接到蓝牙 TX 引脚的设备的 Arduino RX 引脚接收到的数据传递给 Android?我想我必须从 arduino 发送并从 IDE 对其进行编程.希望得到您的帮助,谢谢!

I have a device connected to pins RX and TX of my Arduino UNO and I need more pins RX and TX to send data via bluetooth to Android. I plan to use two pins SoftwareSerial to convert into RX and TX for use with the Bluetooth module. I suppose it's possible. I have read on the subject but most I've found is to make the connection and send data from Android to Arduino. I think with me it would be possible Amarino library. If so far everything I have planned well, I have a big doubt. How do I pass the data received by the Arduino RX pin of the device that I have connected to the TX pin of the bluetooth to send to Android? I guess I'll have to send from arduino and program it from the IDE. I hope your help, thanks!

推荐答案

听起来你只是想让代码在串口之间传输

Sounds like you just want the code to transfer between Serial Ports

void loop() {
...
  while (Serial1.available()) {
    Serial2.write((uint8_t ) Serial1.read());
  }
  while (Serial2.available()) {
    Serial1.write((uint8_t ) Serial2.read());
  }
...

它只是从 Serial1 读取一个字节(如果可用)并将其发送到 Serial2 直到为空,反之亦然.其中 Serial1 和 Serial2 可以替换为您的 SoftwareSerial 对象.请记住高通过但可能会饱和,因为此示例不是限制性的.但典型的串行端口应该没问题.

Which simply reads a byte from Serial1 if available and sends it to Serial2 until empty and vice versa. Where Serial1 and Serial2 can be replaced with your SoftwareSerial Objects. Keep in mind High through but could saturate as this example is not limiting. but typical Serial ports should be fine.

这篇关于2 RX 和 2 TX 将数据从 Arduino 发送到 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆