我正在使用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");
}
}
非常感谢任何帮助......
答案 0 :(得分:0)
您是否尝试过Adafruit图书馆?
它工作得很好而且速度很快我没有注意到任何延迟。 我顺便使用nRF8001模块
#include "Adafruit_BLE_UART.h"