Arduino Bluetooth Basics


[tabby title=”Overview”]
This video will show you the basics of controlling an Arduino through bluetooth. Click the “Step” tags for a walkthrough!


[tabby title=”Step 1″]

Acquiring the Parts
Here’s what you will need:

  • A Bluetooth Capable Smartphone (I’ll be using an Android).
  • An Arduino ($10.99)
  • An Arduino Bluetooth Module ($6.45)
  • An LED ($0.99)

[tabby title=”Step 2″]

Wiring

You can download the Fritzing sketch here.

Screen Shot 2014-03-08 at 7.38.33 PM

[tabby title=”Step 3″]

Software

Android

A good Android program for Arduino is called Ardudroid on the Google Play store.

 

Arduino

 
int ledPin = 13; 
int state = 0;
int flag = 0; 
 
void setup() {
 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);
 
 Serial.begin(9600); // Default connection rate for my BT module
}
 
void loop() {

 if(Serial.available() > 0){
 state = Serial.read();
 flag=0;
 }

 if (state == '0') {
 digitalWrite(ledPin, LOW);
 if(flag == 0){
 Serial.println("LED: off");
 flag = 1;
 }
 }

 else if (state == '1') {
 digitalWrite(ledPin, HIGH);
 if(flag == 0){
 Serial.println("LED: on");
 flag = 1;
 }
 }
}

[tabby title=”Links”]

Follow Tinkernut!
Google +
Facebook
Twitter
[tabbyending]

 

5 Responses


  • edmandowling // //

    Hi, I have done the set up as shown and I have connected the bluetooth module to my phone but when I try send information to turn off the LED, nothing happens. It I have the LED set HIGH in setup and try to turn it off via blutooth nothing happens. Any advice how to solve this for me?

  • schwad // //

    I am having the same problem as edmandowling. I am using the HC-06, will this make any difference?

Leave a Reply