简体   繁体   English

Arduino和Android之间的蓝牙串行通信问题

[英]Bluetooth serial communication issue between Arduino and Android

I have written an application for Android in Java using Eclipse to send data to an Arduino via Bluetooth. 我已经使用Eclipse用Java编写了一个Android应用程序,用于通过蓝牙将数据发送到Arduino。

The devices seem to be connected okay, but when I send data from the Android to the Arduino the receive (RX) light on the Arduino board doesn't light up. 设备似乎连接正确,但是当我从Android向Arduino发送数据时,Arduino板上的接收(RX)灯不亮。

Can someone help? 有人可以帮忙吗?

#define arduinoRx 2
#define arduinoTx 3 
int gelen_veri;
int LedCikis = 8;

SoftwareSerial bluetooth(arduinoRx, arduinoTx);    

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

void loop() {
    if (bluetooth.available() > 0) {

        gelen_veri=bluetooth.read();    

        switch (gelen_veri) {

            case 'A' :
                digitalWrite(LedCikis, HIGH);
            break;

            case 'K' :
                digitalWrite(LedCikis, LOW);
            break;

            default:
            break;
        }
    }
}

Use the serial rx/tx pins instead of SoftwareSerial. 使用串行rx / tx引脚代替SoftwareSerial。 I've had problems with SoftwareSerial in the past and my HC-05 bluetooth module. 过去,我在使用SoftwareSerial和HC-05蓝牙模块时遇到问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM