I have worried my Arduino nano with Flex sensor & servo motor and here is the Arduino code
( #include <SoftwareSerial.h>
SoftwareSerial BTserial(4, 2); // RX | TX
char c = ' ';
void setup()
{
// start th serial communication with the host computer
Serial.begin(9600);
Serial.println("Arduino with HC-05 is ready");
// start communication with the HC-05 using 38400ا
BTserial.begin(9600);
Serial.println("BTserial started at 38400");
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
{
c = Serial.read();
// mirror the commands back to the serial monitor
// makes it easy to follow the commands
Serial.write(c);
BTserial.write(c);
}
}
)
I’m trying to control it via Bluetooth using an android app and here is my code
I have used the Bluetooth adaptor, socket, putting the UID of HC-05 Bluetooth module in my code but got stuck on initializing the Bluetooth connection and start controlling
Please suggest to me how to make it work
I used a flex sensor
// start communication with the HC-05 using 38400ا
BTserial.begin(9600);
Serial.println("BTserial started at 38400");
It's always good if you can trust the information you get on the debug serial interface as well as the comments. If you don't want to tell the actual value remove the wrong value completely.
I'm trying to control it via Bluetooth using an android app and here is my code
That code only copies bytes from the Bluetooth adapter to the PC serial interface and vice versa. I cannot see any code that handles the flex sensor or does anything else. Did you forget to post the code that does what you told us?
bushrayousi:
// start communication with the HC-05 using 38400ا
BTserial.begin(9600);
Serial.println("BTserial started at 38400");
I'm betting it didn't, this is obviously nonsense, and you are going to have make up your mind about which speed you want to use. Since you mention 38400, it is possible that you are trying to use HC-05 in AT mode, in which case don't. Leave it in communications mode and indeed 9600 baud.
I have no idea of what you are trying to do. The last sentence in Pylon's post certainly makes sense. Since you do mention Android, you might find the following background notes useful.