简体   繁体   中英

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.

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.

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. I've had problems with SoftwareSerial in the past and my HC-05 bluetooth module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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