I've got an Arduino Uno (Elegoo R3) and a Hc-05 bluetooth module. First of all i want to send data with an android app (Bluetooth terminal) to the Arduino and turn pin 13 (LED) on.
My Arduino code:
#include <SoftwareSerial.h>
int state = 0;
void setup() {
//Serial.begin(38400);
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
state = Serial.read();
if (state == '1') {
Serial.println("Turned on LED");
digitalWrite(13, HIGH);
}
if (state == '0') {
Serial.println("Turned off LED");
digitalWrite(13, LOW);
}
}
}
The RX and TX pins I have hooked up with the HC-05 but if I connect my smartphone with the HC-05 and type in a 1 or a 0 nothing happens. If I type a 1 or a 0 in my serial monitor on my computer (hooked up via usb to my arduino) it turns the LED on/off. The RX and TX lights also flashes one time. The bluetooth terminal app recognises all what was sent via serial monitor on pc and displays it in the app. But if I type something in the app, it won't flip the LED or show me some "Turned off LED" or "Turned on LED".
I also tried different apps from the PlayStore but all of them didn't work.
Does someone has an idea how I could fix this? Thank you for your answers.
EDIT: A drawing how my Arduino is connected to my HC-05 https://i.stack.imgur.com/N2YsJ.jpg