DFRobot
Published © GPL3+

Bluetooth Smart phone control with remote arduino

Turn an LED on and off using bluetooth connected smart phone with remote arduino.

BeginnerFull instructions provided9,198
Bluetooth Smart phone control with remote arduino

Things used in this project

Story

Read more

Schematics

LED control circuit

When bluetooth connection is completed, we could control LED with Arduino. Let’s send signal to Arduino by bluetooth and turn on and off our LED.

Push button control

Pair it with bluetooth like we did before, and push the button. You would see the digital value, 0 or 1 coming directly on your BlueTerm. If the value is too fast to you can add delay() in your code to slow it down.

Light Sensor control

In this case we could experiment analog sensor with Arduino Bluetooth function. Same as previous works, you could confirm the changing light values in your BlueTerm.

Bluetooth Bee

Before we connect bluetooth to Arduino, we are going to learn about bluetooth bee.
As shown on the picture we can see where each pin is used for. If you want more information go to www.DFRobot.com

I used 4 pins (1,2,3,10) each consists of VCC(+), TX, RX, GND (-). connect these pins to Arduino pins.

Code

LED control

Plain text
At first, connect digital 2 and 3 pins with Bluetooth Bee's Tx and Rx pins. Then connect LED with digital pin 8. And make setup() and loop() functions.
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2,3); 
byte a=0;
int LED=8;
void setup(){
  Serial.begin(9600);
  Serial.println("Hello!");
  BTSerial.begin(9600);
  pinMode(LED,OUTPUT);
}

void loop(){
  if(BTSerial.available()){
      a  = BTSerial.read();
      BTSerial.write(a);
      if(a==49){
      BTSerial.write("led on  ");
      digitalWrite(LED,HIGH);
      }
      if(a==48){
      BTSerial.write("led off  ");
      digitalWrite(LED,LOW);
      }
  }
}

Push button control

Plain text
Connect push button switch with digital pin 13. Make setup() and loop() functions.
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2,3); 
int button = 13; 
void setup(){
  Serial.begin(9600);
  Serial.println("Hello!");
  BTSerial.begin(9600);
  pinMode(button,INPUT);
}

void loop(){
  if(digitalRead(button) == LOW)
  {
    BTSerial.write("0");
  }
  if(digitalRead(button) == HIGH)
  {
    BTSerial.write("1");
  }
}

Light sensor control

Plain text
Connect light sensor (CDs) with analog pin 5. Make setup() and loop() functions.
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2, 3); //Connect HC-06. Use your (TX, RX) settings

void setup()  
{
  Serial.begin(9600);
  Serial.println("Hello!");

  BTSerial.begin(9600);  // set the data rate for the BT port
}

void loop()
{
  int light = analogRead(A5);
  BTSerial.println(light);
  delay(200);
}

Credits

DFRobot
66 projects • 152 followers
Empowering Creation for Future Innovators
Contact

Comments

Please log in or sign up to comment.