I have a problem, which I have been working on for some time. I have an Arduino Uno board and an HC-05 Bluetooth transceiver with TTL outputs.
The connections are as follows:
HC-05 Arduino UNO
----- -----------
RX --> Pin 11
TX --> Pin 10
+5v --> +5v
GND --> GND
The code is as follows:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
String character;
void setup() {
Serial.begin(9600);
pinMode(10, INPUT);
pinMode(11, OUTPUT);
digitalWrite(11, HIGH);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
BTSerial.println("Welcome to ARBA-Beat");
}
void loop() {
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available()) {
character = BTSerial.read();
Serial.println(character);
//BTSerial.write(character);
BTSerial.flush();
}
}
I use Bluetooth terminal app for Android to transmit messages to the Arduino.
The problem is I am getting integer numbers instead of a string.
String: Arduino is great
I have no idea what's happeninng.
Any help appreciated.
Thank you.
Don't use String
and use a char
type.
char c= BTSerial.read();
Serial.write(c); Serial.write('\n');
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.