How to control Arduino wirelessl/ bluetooth by phone
 Leff  2015-12-16 02:48:14 8856 Views0 Replies STEP1: Preparation:
______________________________________________________________________________________________
Hardware:
1. USB to TTL Converter x1
2. Expansion shield x1
3. Phone with BT2.0 above x1
4. BT3.0 module x1
5. DFRobot Uno x1 ( Compatible with Arduino Uno)
Software:
1. Arduino IDE
2. BT serial App for your phone, here I used one for Android (Bluetooth Terminal.apk)
2 APP for Android.zip (1.95 MiB) Downloaded 830 times 
Note: The switch of the AT mode should be on the correct position, or it doesn't work. ![]()
STEP2 Setting BT Module
_______________________________________________________________________________________________
1. Default setting is ok. Visit wiki for how.
STEP3 Download Sketch to Uno
_______________________________________________________________________________________________
plz turn expansion switch "PROG/RUN" to PROG or will cause upload fail. 
 And remember turn it to RUN after finishing uploading. ![]()
The sketch here is to receive the data from serial port ( i.e. BT module), and then, it will
1) Turn On the LED on D13 if you send "1";
2) Turn OFF the LED on D13 if you send "0";
3) Store the command and print out through serial port.
Code: Select allString val = "";
boolean mark = LOW;
void setup() {
  Serial.begin(38400);  //initial the Serial
  pinMode(13, OUTPUT);
}
void loop() {
  while (Serial.available()) {
    val += char(Serial.read());
    delay(2);   // Can't be deleted for it needs time to read serial
    mark = HIGH;
  }
  if (val.length() == 1) {    //Send command without CR/ LF/ NL
    if (val == "1") {
      digitalWrite(13, HIGH); //turn on the LED on D13
      Serial.println("LED is ON!");
    }
    else if (val == "0") {
      digitalWrite(13, LOW);  //Trun off
      Serial.println("LED is OFF!");
    }
  }
  if (mark == HIGH) {
    Serial.print("Length: ");      Serial.println(val.length());
    Serial.print("Val: ");        Serial.println(val); delay(50);
    Serial.println("Done");       Serial.println();
    Serial.flush();
    val = "";
    mark = LOW;
  }
}
STEP4 Connect BT module with your phone
_______________________________________________________________________________________________
1). Connect BT module from SETTING PANEL
______________________________________
2). Open app "Bluetooth Terminal", and set its command sending format as NONE, then send command as you want, here, I sent
1. 1 -> Turn on the LED
2. 0 -> Turn off the LED
3. Test finished! 
______________________________________
One more thing: You can also open Arduino Serial Monitor to receive the feedback info
______________________________________
_______________________________________________________________________________________________

