Go Down

Topic: hc-06 does not respond according to command (Read 6038 times) previous topic - next topic

mitun

Hello!
im using arduino uno and hc-06.I connected hc-06 with uno and when its powered up the lights in uno and bluetooth module blink and i can well understand that when it is paired with my android.primarily im trying to light a led turning on and off using android app.while uploading programs the Rx suddenly blinks and stopped by.then while im trying to send command ,it does not have any effect.I used different apps and programs and changed the port for led but nothing happened.
heres my last code i used,
char val; // variable to receive data from the serial port
int ledpin = 7; // LED connected to pin 48 (on-board LED)

void setup() {

  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(9600);       // start serial communication at 9600bps

}

void loop() {

  if( Serial.available() )       // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
  }
  if( val == '1' )               // if 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else {
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  }
  delay(100);                    // wait 100ms for next reading

}

i made an app at app inventor  in that case.i attached an image of its block.
i used also apps from google play such as BlueLED(code was different),BlueTerm but did not work.
how can i solve this problem?

Nick_Pyner

Your post is unreadable and the problem unclear. It may be that you have simply left the USB cable connected when you try to run the programme.

Here is some background on the procedure that may help.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

mitun

Thanks for your reply.till today i was busy with solving different problems in my arduino boards.at length i have understood many things about arduino.as i am new so it was troublesome to use the Arduino .
But now my poblem is about HC_06 bluetooth module.i am using arduino uno.I connected the hc-06 with arduino.while sending command from android it does not respond.i tried different apps for that but same result.im trying to control two gear motors by using android app.i finished developing an app but while trying to send command the motors does not work.I paired the hc-06 with my android mobile and when my android app gets connected  with hc-06 it stop blinking so i can understand that hc-06 taking data but the motors are not responding.how can i solve this?if you have any question ,please let me know.i may have many errors as im not native english speaker.so sorry for that.

Nick_Pyner


finished developing an app but while trying to send command the motors does not work.I paired the hc-06 with my android mobile and when my android app gets connected  with hc-06 it stop blinking so i can understand that hc-06 taking data but the motors are not responding.how can i solve this?


You might be asking the wrong question. What is not responding? The motors? The HC-06? Nothing you have said suggests there is anything wrong with the HC-06.

You have three problem areas

1. Communication between Android and HC-06. If the light stops blinking, goes solid and stays solid, you have established that

2. Communication between HC-06 and Arduino.  You have not proven this. It may be a simple matter of getting the wires the right way round.

3. Response of motors to commands. This is a separate programming issue, not relevant to this discussion, and a possible impediment to proving item 2.

The link I posted addresses bluetooth, not motors. I suggest you prove the bluetooth first, and then ask about the motors - if you need to.



mitun

Thanks  once again for your response.
According to three problems you mentioned i would like to say that,
1.Communication between Android and HC-06. If the light stops blinking, goes solid and stays solid, you have established that          { YEAH.THAT HAPPENED.}
2. Communication between HC-06 and Arduino.  You have not proven this. It may be a simple matter of getting the wires the right way round.
{HERE IS MY WAY OF WIRING :


HC-06    ---------     ARDUINO UNO
RX           ----            TX
TX          -------           RX
VCC        --------         3.3V
GND       ---------        GND }


3. Response of motors to commands. This is a separate programming issue, not relevant to this discussion, and a possible impediment to proving item 2.

{I SEEM MY PROBLEM IS HERE IN NUMBER 3.
here is my code: https://dl.dropboxusercontent.com/u/257366574/ardu111.txt 
i attached an image of the block of my app that was made in MIT APP INVENTOR.There are 5 buttons which sends byte from 1 to gradually  5.
As i am new to arduino so i might have many errors in my code.but i hope you will have helped me to solve my problem.Please mention if there is any error in my code.should i change the BAUD rate? }
Thanks in advance.

Nick_Pyner



HC-06    ---------     ARDUINO UNO
RX           ----            TX
TX          -------           RX
VCC        --------         3.3V
GND       ---------        GND }


3. Response of motors to commands. This is a separate programming issue, not relevant to this discussion, and a possible impediment to proving item 2.

I SEEM MY PROBLEM IS HERE IN NUMBER 3.



It might be #2. You still have not proven it isn't.
RxTx are kosher, but is the power? What sort of HC-06 is it? If your Bluetooth is on a JY-MCU board, 3.3v might not be enough.  Read the notes. Read what it says on the back of the board. I can't comment on the motors but, since you are using hardware serial, you should be able to prove that section by sending commands from a PC terminal via USB.

mitun

Thanks  for your help...i figured out where my problem is...thanks...
But i have another problem for programming.
heres the link:
http://forum.arduino.cc/index.php?topic=230715.0
hoping your response.
thanks once again.

Nick_Pyner


Thanks  for your help...i figured out where my problem is...thanks...
[/quote}

So where was it?

[quote}
But i have another problem for programming.
heres the link:
http://forum.arduino.cc/index.php?topic=230715.0
hoping your response.



I'm just a data collector. The robot mafia will be better for this.......

pholt_pharmd

Not sure if you figured out what was wrong, but in a similar boat, when I added:

pinMode(0, INPUT_PULLUP);

to my code, everything worked fine.

Go Up