// This program shown how to control arduino LED from PC/Phone Via Bluetooth
// Connect ...
// arduino>>bluetooth
// D5   >>>  Rx
// D3   >>>  Tx
//Rewritten By Robert Cseh (TavIR)

// you will need arduino 1.0.1 or higher to run this sketch

#include <SoftwareSerial.h>// import the serial library

SoftwareSerial swser(5, 3); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer

void setup() {
  // put your setup code here, to run once:
  swser.begin(9600);
  swser.println("Bluetooth On please press 1 or 0 blink LED ..");
  pinMode(ledpin,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
   if (swser.available()){
BluetoothData=swser.read();
   if(BluetoothData=='1'){   // if number 1 pressed ....
   digitalWrite(ledpin,1);
   swser.println("LED  On D13 ON ! ");
   }
  if (BluetoothData=='0'){// if number 0 pressed ....
  digitalWrite(ledpin,0);
   swser.println("LED  On D13 Off ! ");
  }
}
delay(100);// prepare for next data ...
}
