Go Down

Topic: Bluetooth shield not working (Read 1 time) previous topic - next topic

rat97

HI guys,




I wanted to know how to check, if Arduino BT shield and Android are connected? When i connect my Android with Arduino, then the red LED what is on arduino BT shield stops blinking.  But when i am trying to send commands with Android to Arduino i am not sure that Arduino gets them. Is there some good way to check out if my Android commands are able to reach arduino?

My code:

Code: [Select]
char incomingByte = ' ';
int led = 13;// for incoming serial data

void setup() {
        Serial.begin(9600); 
         pinMode(led, OUTPUT);    // opens serial port, sets data rate to 9600 bps
}

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                  String myString = String(incomingByte);
                Serial.println(myString);
                if(incomingByte=='s'){
                 digitalWrite(led, HIGH);
                }if(incomingByte=='v'){
                  digitalWrite(led, LOW);
                }
               
               
        }
}


Sorry about my bad English, i hope u understand

CHeers ;)

Nick_Pyner


When i connect my Android with Arduino, then the red LED what is on arduino BT shield stops blinking. 


If the light stops blinking it probably means the connection has been made. Here is some background that may be useful. If you find it is, please tell me about the shield you are using.

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

pito

The easiest way to check whether your BT module works is to send something from Arduino to your Android.
For example
Code: [Select]
void loop() {
Serial.println("Hello Android!");
delay(100);
}

kerimil

The correct approach here is to makes sure arduino receives anything in the first place. Create a sketch that will light an LED whenever the board receives anything through serial. Once you establish that it is indeed true you pretty much have two options left:
1. your app sends something else than you think it's sending
2. your sketch doesn't work the way it should
3. both option 1&2

Whenever you have problems with communication you have to establish which device is causing problems. To establish that try to send data to the arduino through USB instead - send what you think the app should be sending and see if it reacts the way it should. Then do the same with the app - connect to your PC instead (not the BT shield/module) and use program such as putty to see the output.

Go Up