Bluetooth heaven

Apr 16, 2012 No Comments by

I have for a long time dreamed about connecting my Arduino with bluetooth, and in fact I have owned two bluetooth modules since early 2011. So now it was really time to get cracking, there is only two weeks until my master thesis is originally due, so why not do something completely different, right.

The last time I tried to get the bluetooth modules to work I sat a couple of hours scratching my head and googled every bluetooth-Arduino search phrase possible without getting it to work, but today a little epiphany came to me while I was sitting and trying to get it to work once more.It turned out that I had neglected a tiny detail that turned out to be rather essential.

My super simple bluetooth module is so super simple, and designed with Arduino in mind, that it does in fact not communicate over bluetooth on the regular bluetooth baud rate(115200) but uses the standard Arduino baud rate (9600). This means that it is a little slower then regular bluetooth, but still several hundreds times faster then me when I am speaking.

After putting the new settings in the Arduino code and into Putty I was able to communicate and turn my first led on and off over bluetooth, it was amazing.

The code I used is super simple and can be used with either bluetooth or regulare serial communication, and if I don’t remember wrong it is the same as with xBee aswell.

 

char val;       
int ledpin = 13;

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

void loop() {
  if( Serial.available() )
  {
    val = Serial.read();

    if( val == '0' )            
    {
     digitalWrite(ledpin, LOW);
     Serial.println("13 off");
    }

    if( val == '1' )              
    {
      digitalWrite(ledpin, HIGH); 
      Serial.println("13 on");
    }
  }
}

So now it is time for me to create a nice thing to hang on my wall that can tell me everything from how many email Ihave to read, how warm or cold it is outside, if someone tweeted to me, if I have a notification on facebook and so on. Or it is just time to put the modules back into the box and forget them untill my master thesis is delivered.

Arduino, DIY

About the author

Sometime I write, sometime I don't. But most of the time I program, build a curcuit or just do something completely different.
No Responses to “Bluetooth heaven”

Leave a Reply