user57506: I have been trying to use the HC-05 Module with my Arduino Uno to control a LED, which can be turned on and off by my phone. Everything is fine when i input the values from the serial monitor. The problem only occurs when I use my phone. I am using a bluetooth terminal for HC-05 and it shows it connected. The bluetooth module is conected as its blinking slows down when I use the app.
Here's the code:
#define ledPin 8
int state = 0;

void setup() {
 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);
 Serial.begin(38400); /
}

void loop() {
 if(Serial.available() > 0){ // Checks whether data is comming from the serial port
 state = Serial.read(); 
 }                                       
 if (state == '0') {
 digitalWrite(ledPin, LOW); 
 Serial.println("LED: OFF");
 state = 0;
 }
 else if (state == '1') {
 digitalWrite(ledPin, HIGH);
 Serial.println("LED: ON");;
 state = 0;
 } 
}

Here's the serial monitor output;

Appreciate the Help!

user25597: Few Points that you might want to Look into.

Where exactly are you connecting Bluetooth Module with Uno. Make sure you are connecting it with Rx and Tx Pin Only.
First make Simple Program to send some data on Serial Say "Hello World" at every 1second and make sure your Bluetooth is connected to Hardware Serial Pins only. If you receive data on phone then you are good to receive as well If not then Try below points.
Make sure your HC-05 Baudrate is correct. If you are not sure then try some others as well like 9600, 115200 etc.
Make sure Rx and Tx pins are connect with correct pins of HC-05. If you know your Baudrate then try swapping Rx Tx and it should response to you.


57506: <p>I have been trying to use the <strong>HC-05 Module</strong> with my <strong>Arduino Uno</strong> to control a LED, which can be turned on and off by my phone. Everything is fine when i input the values from the serial monitor. The problem <strong>only occurs when I use my phone</strong>. I am using a bluetooth terminal for HC-05 and it shows it connected. The <strong>bluetooth module is conected</strong> as its blinking slows down when I use the app.</p>

<p>Here's the code:</p>

<pre><code>#define ledPin 8
int state = 0;

void setup() {
 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);
 Serial.begin(38400); /
}

void loop() {
 if(Serial.available() &gt; 0){ // Checks whether data is comming from the serial port
 state = Serial.read(); 
 }                                       
 if (state == '0') {
 digitalWrite(ledPin, LOW); 
 Serial.println("LED: OFF");
 state = 0;
 }
 else if (state == '1') {
 digitalWrite(ledPin, HIGH);
 Serial.println("LED: ON");;
 state = 0;
 } 
}
</code></pre>

<p>Here's the serial monitor output;</p>

<p><a href="https://i.stack.imgur.com/cB4Vf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cB4Vf.png" alt="enter image description here"></a>
Appreciate the Help!</p>
 25597: <p>Few Points that you might want to Look into.</p>

<ol>
<li>Where exactly are you connecting Bluetooth Module with Uno. Make sure you are connecting it with Rx and Tx Pin Only.</li>
<li>First make Simple Program to send some data on Serial Say "Hello World" at every 1second and make sure your Bluetooth is connected to Hardware Serial Pins only. If you receive data on phone then you are good to receive as well If not then Try below points.</li>
<li>Make sure your HC-05 Baudrate is correct. If you are not sure then try some others as well like 9600, 115200 etc.</li>
<li>Make sure Rx and Tx pins are connect with correct pins of HC-05. If you know your Baudrate then try swapping Rx Tx and it should response to you.</li>
</ol>
