Loading...
Pages: [1]   Go Down
Author Topic: Bluetooth HC-06 returns 3 times the same  (Read 286 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I am trying to comunicate an arduino UNO with android using the famous HC-06 bluetooth module.
Sending things (char,Strings...) from android using a bluetooth terminal app works fine, the problem is that when I use Serial.println to send things to android from arduino it works but I always get what I sent 3 times repeated. I don´t know why, the bluetooth module is with stock configuration, I don't used any AT commands for nothing.

This is the code in arduino:
Code:
char INBYTE;
int  LED = 13; // LED on pin 13

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
}
 
void loop() {

  Serial.println("bla bla bla");
  while (!Serial.available());   // stay here so long as COM port is empty   
  INBYTE = Serial.read();        // read next available byte
  if( INBYTE == '0' ) digitalWrite(LED, LOW);  // if it's a 0 (zero) tun LED off
  if( INBYTE == '1' ) digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
  delay(50);
}

On android side I tryed several bluetooth terminal app's and all does the same, I always get:
bla bla bla
bla bla bla
bla bla bla

Thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems that the problem were the bluetooth terminal applications, they send something like '\n' or anything like this that I was not counting with.
Logged

Pages: [1]   Go Up
Print
 
Jump to: