【问题标题】:Bluetooth latency from Arduino to Android从 Arduino 到 Android 的蓝牙延迟
【发布时间】:2015-01-09 06:25:27
【问题描述】:

我正在使用 arduino 和 App Inventor 构建一个简单的压电鼓。 在 arduino 代码中,当达到压电阈值时,我通过蓝牙发送一个“a”。

另一方面,在三星 S2 手机中,有一个在 Android 上运行的 App Inventor 应用程序。 当收到“a”键时,应用程序只会播放声音。

我面临的问题是延迟......你知道一些减少它的方法吗?也许使用其他库而不是 SoftwareSerial?我尝试了其他应用程序(蓝牙 SPP 等),结果相同。

Arduino代码很简单:

#include <SoftwareSerial.h>

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

const int threshold= 30;
int val;

void setup()
{
  bluetooth.begin(115200);
}

void loop()
{
  val = analogRead(sensorPin);

  if (val >= threshold)
  {
    bluetooth.print("a");
  }
} 

任何帮助将不胜感激...

【问题讨论】:

    标签: android bluetooth latency


    【解决方案1】:

    您尝试过 Adafruit 库吗?

    它运行得非常好,速度非常快,我没有注意到任何延迟。 顺便说一下,我用的是nRF8001模块

    #include "Adafruit_BLE_UART.h"
    

    https://github.com/adafruit/Adafruit_Android_BLE_UART

    【讨论】:

    • 谢谢马特,我正在使用蓝牙 hc-05 模块。 adafruit 库是否适用于该模块?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多